File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
graalpython/lib-graalpython Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,34 @@ def __reduce__(self):
5656
5757
5858defaultdict .__module__ = 'collections'
59+
60+
61+ class _tuplegetter (object ):
62+ def __init__ (self , index , doc ):
63+ self .index = index
64+ self .__doc__ = doc
65+
66+ @__graalpython__ .builtin_method
67+ def __set__ (self , instance , value ):
68+ raise AttributeError ("can't set attribute" )
69+
70+ @__graalpython__ .builtin_method
71+ def __delete__ (self , instance ):
72+ raise AttributeError ("can't delete attribute" )
73+
74+ @__graalpython__ .builtin_method
75+ def __get__ (self , instance , owner = None ):
76+ index = self .index
77+ if not isinstance (instance , tuple ):
78+ if instance is None :
79+ return self
80+ raise TypeError ("descriptor for index '%d' for tuple subclasses "
81+ "doesn't apply to '%s' object" , index , instance )
82+ if index >= len (instance ):
83+ raise IndexError ("tuple index out of range" )
84+
85+ return instance [index ]
86+
87+ @__graalpython__ .builtin_method
88+ def __reduce__ (self ):
89+ return type (self ), (self .index , self .__doc__ )
You can’t perform that action at this time.
0 commit comments