@@ -193,21 +193,21 @@ def unwrap(self):
193193# Note: Use these with care!
194194# In some situations - in particular *args/**kwargs, Python creates tuples and dicts for us,
195195# these functions are intended to do the appropriate wrapping for them.
196- def wrap_args_from_list (l ): # returns a new list!
197- res = [_interpret_call (lambda l , i : l [i ], l , wrap_const (i )) for i in range (len (unwrap (l )))]
196+ def wrap_args_from_list (lst ): # returns a new list!
197+ res = [_interpret_call (lambda seq , i : seq [i ], lst , wrap_const (i )) for i in range (len (unwrap (lst )))]
198198 return res
199199
200200
201201def wrap_kwargs_from_dict (d ): # returns a new dict
202202 return {k : _interpret_call (lambda d , k : d [k ], d , wrap_const (k )) for k in unwrap (d )}
203203
204204
205- def wrapped_build_tuple (l : Sequence [WrappedValue ]) -> WrappedValue :
206- assert all (isinstance (v , WrappedValue ) for v in l )
207- if l :
208- pr = ProvenanceRecord (PseudoInst .BUILD_TUPLE , inputs = [v .provenance for v in l ][::- 1 ]) # other inst?
209- out = wrap (tuple (v .value for v in l ), provenance = pr )
210- out .item_wrappers = list (l )
205+ def wrapped_build_tuple (seq : Sequence [WrappedValue ]) -> WrappedValue :
206+ assert all (isinstance (v , WrappedValue ) for v in seq )
207+ if seq :
208+ pr = ProvenanceRecord (PseudoInst .BUILD_TUPLE , inputs = [v .provenance for v in seq ][::- 1 ]) # other inst?
209+ out = wrap (tuple (v .value for v in seq ), provenance = pr )
210+ out .item_wrappers = list (seq )
211211 else :
212212 # Note: if we revisit returning const here instead of an empty tuple from BUILD_TUPLE, we need to add this to wrap_aergs
213213 out = wrap_const (())
@@ -336,36 +336,36 @@ def wrap_binary_subscr(uvalue, obj, key):
336336 return wrap (uvalue , provenance = ProvenanceRecord (PseudoInst .BINARY_SUBSCR , inputs = [obj .provenance , key .provenance ]))
337337
338338
339- def populate_item_wrappers (l ):
339+ def populate_item_wrappers (obj ):
340340 ctx : InterpreterCompileCtx = get_interpretercompilectx ()
341341 if not ctx ._with_provenance_tracking :
342342 return
343343
344- assert isinstance (l , WrappedValue )
344+ assert isinstance (obj , WrappedValue )
345345 # to do: generalize
346- if wrapped_isinstance (l , (list , tuple )):
347- if l .item_wrappers is None :
348- l .item_wrappers = [None for _ in range (len (l .value ))]
349- assert isinstance (l .item_wrappers , list )
350- assert len (l .value ) == len (l .item_wrappers ), f"{ len (l .value )= } { len (l .item_wrappers )= } "
351-
352- for i , v in enumerate (l .value ):
353- if l .item_wrappers [i ] is None :
354- wv = wrap_binary_subscr (v , l , i )
355- l .item_wrappers [i ] = wv
346+ if wrapped_isinstance (obj , (list , tuple )):
347+ if obj .item_wrappers is None :
348+ obj .item_wrappers = [None for _ in range (len (obj .value ))]
349+ assert isinstance (obj .item_wrappers , list )
350+ assert len (obj .value ) == len (obj .item_wrappers ), f"{ len (obj .value )= } { len (obj .item_wrappers )= } "
351+
352+ for i , v in enumerate (obj .value ):
353+ if obj .item_wrappers [i ] is None :
354+ wv = wrap_binary_subscr (v , obj , i )
355+ obj .item_wrappers [i ] = wv
356356 return
357357
358- if wrapped_isinstance (l , dict ):
359- assert isinstance (l .item_wrappers , dict )
360- for k , v in l .value .items ():
361- if k not in l .item_wrappers :
358+ if wrapped_isinstance (obj , dict ):
359+ assert isinstance (obj .item_wrappers , dict )
360+ for k , v in obj .value .items ():
361+ if k not in obj .item_wrappers :
362362 wk = wrap_const (k )
363- wv = wrap_binary_subscr (v , l , wk )
364- l .item_wrappers [k ] = wv
365- l .key_wrappers [k ] = wk # or have those from an iteration of the input?
363+ wv = wrap_binary_subscr (v , obj , wk )
364+ obj .item_wrappers [k ] = wv
365+ obj .key_wrappers [k ] = wk # or have those from an iteration of the input?
366366 return
367367
368- raise NotImplementedError (f"populate item wrappers for { type (l .value )} " )
368+ raise NotImplementedError (f"populate item wrappers for { type (obj .value )} " )
369369
370370
371371#
@@ -883,15 +883,15 @@ def __init__(self, frame: FrameType):
883883
884884 def format_with_source (self ):
885885 assert self .positions is not None , self
886- l = []
887- l .append (f" in { self .qualname } in file: { self .code .co_filename } , line { self .positions .lineno } :" )
886+ lst = []
887+ lst .append (f" in { self .qualname } in file: { self .code .co_filename } , line { self .positions .lineno } :" )
888888 if self .code .co_filename :
889889 ls = linecache .getlines (self .code .co_filename )
890890 lineno = self .positions .lineno
891891 if lineno is None :
892892 lineno = self .code .co_firstlineno
893- l .append (" " + ls [max (lineno - 1 , 0 )].rstrip ())
894- return os .linesep .join (l )
893+ lst .append (" " + ls [max (lineno - 1 , 0 )].rstrip ())
894+ return os .linesep .join (lst )
895895
896896 def get_or_make_python_frame (self ) -> FrameType :
897897 return self .frame
@@ -980,10 +980,10 @@ def recurse_str(self):
980980 inputs = [recurse_str (i ) for i in self .inputs ]
981981 inputs_str = ", " .join (inputs )
982982 counter += 1
983- l = f" i{ counter } = { self .inst } ({ inputs_str } )"
983+ out_item = f" i{ counter } = { self .inst } ({ inputs_str } )"
984984 if self .output_idx != 0 or self .output_key is not None :
985- l += "# with output spec"
986- out .append (l )
985+ out_item += "# with output spec"
986+ out .append (out_item )
987987 res = f"i{ counter } "
988988 known [self ] = res
989989 return res
@@ -1034,11 +1034,11 @@ def unpack_provenance_record(self, wrapped_value, key: int | slice | None = None
10341034 return wrapped_value
10351035 # key=None is pop
10361036 if isinstance (key , slice ):
1037- l = len (self ._stack )
1037+ length = len (self ._stack )
10381038 if key .start is not None :
10391039 start = key .start
10401040 else :
1041- start = - l
1041+ start = - length
10421042 assert start < 0
10431043 if key .step is not None :
10441044 step = key .step
@@ -1156,18 +1156,18 @@ def nexti(self, inst: dis.Instruction):
11561156 def format_with_source (self ) -> str :
11571157 # todo: multiple lines in positions, underline, indent
11581158 assert self .positions is not None , self
1159- l = []
1160- l .append (f" in { self .qualname } in file: { self .code .co_filename } , line { self .positions .lineno } :" )
1159+ lines = []
1160+ lines .append (f" in { self .qualname } in file: { self .code .co_filename } , line { self .positions .lineno } :" )
11611161 if self .code .co_filename :
11621162 ls = linecache .getlines (self .code .co_filename )
11631163 if ls :
11641164 lineno = self .positions .lineno
11651165 if lineno is None :
11661166 lineno = self .code .co_firstlineno
1167- l .append (" " + ls [max (lineno - 1 , 0 )].rstrip ())
1167+ lines .append (" " + ls [max (lineno - 1 , 0 )].rstrip ())
11681168 else :
1169- l .append (" <unavailable>" )
1170- return os .linesep .join (l )
1169+ lines .append (" <unavailable>" )
1170+ return os .linesep .join (lines )
11711171
11721172 def get_localsplus_name (self , idx : int ) -> str :
11731173 if sys .version_info < (3 , 11 ):
@@ -1194,7 +1194,7 @@ def get_or_make_python_frame(self) -> FrameType:
11941194 name = self .code .co_name
11951195 qualname = self .qualname
11961196
1197- def get_frame (l , rel_lineno , filename , firstlineno , name , qualname ):
1197+ def get_frame (container , rel_lineno , filename , firstlineno , name , qualname ):
11981198 def fn ():
11991199 pass
12001200
@@ -1219,7 +1219,7 @@ def fn():
12191219 assert tb is not None
12201220 while tb .tb_next is not None :
12211221 tb = tb .tb_next
1222- l .append (tb .tb_frame )
1222+ container .append (tb .tb_frame )
12231223
12241224 # we run the getting of the frame in a separate thread because
12251225 # we want to avoid having f_back pointing to the function
@@ -2133,15 +2133,15 @@ class SequenceWrapperMethods(WrappedValue):
21332133 def __init__ (self , iterable = (), / ):
21342134 if iterable == ():
21352135 iterable = wrap_const (())
2136- l = wrap_const ([])
2137- assert l .item_wrappers is not None
2136+ wrapped_list = wrap_const ([])
2137+ assert wrapped_list .item_wrappers is not None
21382138
2139- res = _interpret_call (list .extend , l , iterable )
2139+ res = _interpret_call (list .extend , wrapped_list , iterable )
21402140 if res is INTERPRETER_SIGNALS .EXCEPTION_RAISED :
21412141 return res
21422142 assert type (self .value ) is self .python_typ
2143- self .value [:] = l .value [:]
2144- self .item_wrappers = l .item_wrappers [:]
2143+ self .value [:] = wrapped_list .value [:]
2144+ self .item_wrappers = wrapped_list .item_wrappers [:]
21452145 return wrap_const (None )
21462146
21472147 def __getitem__ (self , idx , / ):
@@ -2195,10 +2195,10 @@ def __mul__(self, n, /):
21952195 self .track_items ()
21962196
21972197 def impl (self , n ):
2198- l = []
2198+ seq = []
21992199 for _ in range (n ):
2200- l .extend (self )
2201- return type (self )(l )
2200+ seq .extend (self )
2201+ return type (self )(seq )
22022202
22032203 return _interpret_call (impl , self , n )
22042204
@@ -2336,9 +2336,9 @@ def extend(self, iterable, /):
23362336
23372337 if not isinstance (iterable .value , (tuple , list )):
23382338
2339- def impl (l , iterable ):
2339+ def impl (seq , iterable ):
23402340 for i in iterable :
2341- l .append (i )
2341+ seq .append (i )
23422342
23432343 res = _interpret_call (impl , self , iterable )
23442344 assert len (self .value ) == len (self .item_wrappers )
@@ -2392,7 +2392,7 @@ def pop(self, index=-1, /):
23922392 if uindex < - len (uself ) or uindex >= len (uself ):
23932393 return do_raise (IndexError ("pop index out of range" ))
23942394
2395- res = _interpret_call (lambda l , i : l [i ], self , index )
2395+ res = _interpret_call (lambda seq , i : seq [i ], self , index )
23962396
23972397 assert res is not INTERPRETER_SIGNALS .EXCEPTION_RAISED
23982398
@@ -2873,7 +2873,7 @@ def _tuple_new_provenance_tracking_lookaside(cls, iterable=(), /):
28732873 item_wrappers = []
28742874 # TODO: investigate why just taking the wrappers will break test_interpreter.py::test_module_hooks
28752875 for i in range (len (iterable .value )):
2876- item_wrappers .append (_interpret_call (lambda l , i : l [i ], iterable , wrap_const (i )))
2876+ item_wrappers .append (_interpret_call (lambda seq , i : seq [i ], iterable , wrap_const (i )))
28772877 else :
28782878 iterator = _interpret_call (iter , iterable )
28792879 if iterator is INTERPRETER_SIGNALS .EXCEPTION_RAISED :
@@ -4818,14 +4818,14 @@ def _list_append_handler(inst: dis.Instruction, /, stack: InterpreterStack, **kw
48184818
48194819 # NOTE Doesn't pop the list that's extended
48204820 tos = stack .pop_wrapped ()
4821- l : list = stack .getitem_wrapped (- i )
4821+ lst : list = stack .getitem_wrapped (- i )
48224822
4823- assert wrapped_isinstance (l , list )
4823+ assert wrapped_isinstance (lst , list )
48244824
4825- def impl (l , tos ):
4826- l .append (tos )
4825+ def impl (lst , tos ):
4826+ lst .append (tos )
48274827
4828- res = _interpret_call (impl , l , tos )
4828+ res = _interpret_call (impl , lst , tos )
48294829 if res is INTERPRETER_SIGNALS .EXCEPTION_RAISED :
48304830 return res
48314831
@@ -4838,11 +4838,11 @@ def _list_extend_handler(inst: dis.Instruction, /, stack: InterpreterStack, **kw
48384838
48394839 # NOTE Doesn't pop the list that's extended
48404840 tos = stack .pop_wrapped ()
4841- l : list = stack .getitem_wrapped (- i )
4841+ lst : list = stack .getitem_wrapped (- i )
48424842
48434843 # NOTE tos does not have to be a list
4844- assert wrapped_isinstance (l , list )
4845- res = _interpret_call (lambda l1 , l2 : l1 .extend (l2 ), l , tos )
4844+ assert wrapped_isinstance (lst , list )
4845+ res = _interpret_call (lambda l1 , l2 : l1 .extend (l2 ), lst , tos )
48464846
48474847 if res is INTERPRETER_SIGNALS .EXCEPTION_RAISED :
48484848 return res
0 commit comments