[ 
https://issues.apache.org/jira/browse/BEAM-3143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16273926#comment-16273926
 ] 

ASF GitHub Bot commented on BEAM-3143:
--------------------------------------

luke-zhu commented on a change in pull request #4183: [BEAM-3143] Type 
Inference Python 3 Compatibility
URL: https://github.com/apache/beam/pull/4183#discussion_r154266176
 
 

 ##########
 File path: sdks/python/apache_beam/typehints/trivial_inference.py
 ##########
 @@ -303,15 +310,21 @@ def infer_return_type_func(f, input_types, debug=False, 
depth=0):
   last_pc = -1
   while pc < end:
     start = pc
-    op = ord(code[pc])
-
+    try:
+      op = ord(code[pc])
+    except TypeError:
+      op = code[pc]
     if debug:
       print('-->' if pc == last_pc else '    ', end=' ')
       print(repr(pc).rjust(4), end=' ')
       print(dis.opname[op].ljust(20), end=' ')
+
     pc += 1
     if op >= dis.HAVE_ARGUMENT:
-      arg = ord(code[pc]) + ord(code[pc + 1]) * 256 + extended_arg
+      try:
 
 Review comment:
   Yeah it's more clear this way. I've changed it to use if/else.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Fix type inference in Python 3 for generators
> ---------------------------------------------
>
>                 Key: BEAM-3143
>                 URL: https://issues.apache.org/jira/browse/BEAM-3143
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: holdenk
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to