66 raw_input = input
77
88import 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
1011
1112
1213class BuiltinModule (pyobjects .AbstractModule ):
@@ -271,7 +272,7 @@ def __init__(self, holding=None):
271272 collector ('__getitem__' , function = self ._list_get )
272273 collector ('pop' , function = self ._list_get )
273274 try :
274- collector ('__getslice__' , function = self ._self_get )
275+ collector ('__getslice__' , function = self ._list_get )
275276 except AttributeError :
276277 pass
277278
@@ -297,6 +298,10 @@ def _self_set(self, context):
297298
298299 def _list_get (self , context ):
299300 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 )
300305 return self .holding
301306 return context .get_per_name ()
302307
@@ -414,7 +419,7 @@ def __init__(self, *objects):
414419 if objects :
415420 first = objects [0 ]
416421 attributes = {
417- '__getitem__' : BuiltinName (BuiltinFunction (first )),
422+ '__getitem__' : BuiltinName (BuiltinFunction (first )), # TODO: add slice support
418423 '__getslice__' :
419424 BuiltinName (BuiltinFunction (pyobjects .PyObject (self ))),
420425 '__new__' : BuiltinName (BuiltinFunction (function = self ._new_tuple )),
@@ -656,12 +661,12 @@ def get_name(self):
656661 return 'lambda'
657662
658663 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 )]
661666 if self .arguments .vararg :
662- result .append ('*' + self .arguments .vararg )
667+ result .append ('*' + pycompat . get_ast_arg_arg ( self .arguments .vararg ) )
663668 if self .arguments .kwarg :
664- result .append ('**' + self .arguments .kwarg )
669+ result .append ('**' + pycompat . get_ast_arg_arg ( self .arguments .kwarg ) )
665670 return result
666671
667672 @property
@@ -801,4 +806,4 @@ def _input_function(args):
801806 builtin = raw_input )),
802807}
803808
804- builtins = BuiltinModule ('__builtin__' , initial = _initial_builtins )
809+ builtins = BuiltinModule (pycompat . builtins . __name__ , initial = _initial_builtins )
0 commit comments