jrmccluskey commented on code in PR #25795:
URL: https://github.com/apache/beam/pull/25795#discussion_r1134164367


##########
sdks/python/apache_beam/typehints/trivial_inference.py:
##########
@@ -408,17 +418,27 @@ def infer_return_type_func(f, input_types, debug=False, 
depth=0):
         if op in dis.hasconst:
           print('(' + repr(co.co_consts[arg]) + ')', end=' ')
         elif op in dis.hasname:
-          print('(' + co.co_names[arg] + ')', end=' ')
+          if (sys.version_info.major, sys.version_info.minor) >= (3, 11):
+            # Pre-emptively bit-shift so the print doesn't go out of index
+            printArg = arg >> 1

Review Comment:
   It's actually the mechanics in 3.11 for free vars, prior to this you'd have 
you'd just get an int arg and return the value out but in 3.11 the bit that 
gets shifted out matters on the CPython side for deciding whether or not to 
push a NULL on the stack. We don't sweat this implementation detail since it 
doesn't seem to matter much to us, we just shift the value to avoid an index 
out of range for debug printing and retrieve the proper index in LOAD_GLOBAL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to