[
https://issues.apache.org/jira/browse/BEAM-3143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16273718#comment-16273718
]
ASF GitHub Bot commented on BEAM-3143:
--------------------------------------
holdenk commented on a change in pull request #4183: [BEAM-3143] Type Inference
Python 3 Compatibility
URL: https://github.com/apache/beam/pull/4183#discussion_r154240171
##########
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:
Maybe here (and in other places) it would make more sense to check for the
version? That way its clearer that one code path is for Py2 and one is for Py3?
With the try/catch its not as clear why we expect the error.
----------------------------------------------------------------
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)