6
6
raw_input = input
7
7
8
8
import rope .base .evaluate
9
- from rope .base import pynames , pyobjects , arguments , utils , ast
9
+ from rope .base .utils import pycompat
10
+ from rope .base import pynames , pyobjects , arguments , utils
10
11
11
12
12
13
class BuiltinModule (pyobjects .AbstractModule ):
@@ -271,7 +272,7 @@ def __init__(self, holding=None):
271
272
collector ('__getitem__' , function = self ._list_get )
272
273
collector ('pop' , function = self ._list_get )
273
274
try :
274
- collector ('__getslice__' , function = self ._self_get )
275
+ collector ('__getslice__' , function = self ._list_get )
275
276
except AttributeError :
276
277
pass
277
278
@@ -297,6 +298,10 @@ def _self_set(self, context):
297
298
298
299
def _list_get (self , context ):
299
300
if self .holding is not None :
301
+ args = context .get_arguments (['self' , 'key' ])
302
+ if (len (args ) > 1 and args [1 ] is not None and
303
+ args [1 ].get_type () == builtins ['slice' ].get_object ()):
304
+ return get_list (self .holding )
300
305
return self .holding
301
306
return context .get_per_name ()
302
307
@@ -414,7 +419,7 @@ def __init__(self, *objects):
414
419
if objects :
415
420
first = objects [0 ]
416
421
attributes = {
417
- '__getitem__' : BuiltinName (BuiltinFunction (first )),
422
+ '__getitem__' : BuiltinName (BuiltinFunction (first )), # TODO: add slice support
418
423
'__getslice__' :
419
424
BuiltinName (BuiltinFunction (pyobjects .PyObject (self ))),
420
425
'__new__' : BuiltinName (BuiltinFunction (function = self ._new_tuple )),
@@ -656,12 +661,12 @@ def get_name(self):
656
661
return 'lambda'
657
662
658
663
def get_param_names (self , special_args = True ):
659
- result = [node . id for node in self .arguments .args
660
- if isinstance (node , ast . Name )]
664
+ result = [pycompat . get_ast_arg_arg ( node ) for node in self .arguments .args
665
+ if isinstance (node , pycompat . ast_arg_type )]
661
666
if self .arguments .vararg :
662
- result .append ('*' + self .arguments .vararg )
667
+ result .append ('*' + pycompat . get_ast_arg_arg ( self .arguments .vararg ) )
663
668
if self .arguments .kwarg :
664
- result .append ('**' + self .arguments .kwarg )
669
+ result .append ('**' + pycompat . get_ast_arg_arg ( self .arguments .kwarg ) )
665
670
return result
666
671
667
672
@property
@@ -801,4 +806,4 @@ def _input_function(args):
801
806
builtin = raw_input )),
802
807
}
803
808
804
- builtins = BuiltinModule ('__builtin__' , initial = _initial_builtins )
809
+ builtins = BuiltinModule (pycompat . builtins . __name__ , initial = _initial_builtins )
0 commit comments