Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/python3 support #40

Merged
merged 7 commits into from
Apr 30, 2020

Conversation

robszewczyk
Copy link
Member

No description provided.

In python 3 comparison between different classes is not defined by
default; fix the Jinja template to sort on a common attribute type
instead.

Comparison between int and None is not defined; define suitable fallback
`sys.stdin.read()` and `sys.stdout.write()` methods in Python3 expect
to operate on strings, and thus expect to read/write valid unicode
objects. The protoc python interface expects to be able to
send/receive aribitrary binary streams.   The change here keeps the
existing sys.stdin and sys.stdout objects on Python2 systems and on
Python3 systems, the code uses raw binary IO via `open()` call.
Python3 does not permit dictionaries to be modified during iteration.
Replace the philosophy of deleting the object from a dictionary with
maintaining a list of already completed objects.
In python 3, the result of `struct.pack` is already a
`bytes` object; simply map it to a list for compatibility purposes.
Keep prior mapping via `ord` for cases where `struct.pack` returns
a `str` (i.e. Python2)
@@ -53,7 +53,7 @@ enum {{ enum.base_name }} {
chain(get_struct_dependencies(obj)|reject('common')|map(attribute='parent'))|
chain(get_struct_dependencies(obj)|select('common'))|
reject('false')|unique|reject('standard')|reject('vendor')|
reject('equalto',obj)|sort -%}
reject('equalto',obj)|sort(attribute='full_name') -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated to the Python 3 upgrade. Is it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is VERY much related. In Python2, comparison between unrelated objects would yield a stable result, in Python3, in the absence of a comparison operator, this throws an error. In this case, the objects sorted were derived from a common ancestor, but defined no comparison. When we were comparing Typespace and Trait, the comparison would throw an error. I would note that the new code parallels the structure we've seen in other templates for codegen that have not been opensourced yet.

Copy link
Contributor

@gerickson gerickson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one minor question / clarification.

@@ -3288,7 +3300,7 @@ if ${nl_cv_protoc_version+:} false; then :
$as_echo_n "(cached) " >&6
else

nl_cv_protoc_version=`${PROTOC} --version 2>&1 | ${SED} -n -e 's/^.\{1,\}\([0-9]\{1,\}.[0-9]\{1,\}.[0-9]\{1,\}\)$/\1/gp'`
nl_cv_protoc_version=`${PROTOC} --version 2>&1 | ${SED} -n -E -e 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gerickson you cool with this regex change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be auto-generated and should match what came in via Eli Ribble from commit ea8339e

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this regex change has been previously approved and pulled into configure.ac in #39 ; in this pull request we simply update the automake-generated files. The change was made to support protoc-3.6.1 and similar style of versions

@robszewczyk robszewczyk force-pushed the feature/python3-support branch from a94e66b to 23898b8 Compare April 30, 2020 14:51
@robszewczyk robszewczyk merged commit 8e6176c into openweave:master Apr 30, 2020
@robszewczyk robszewczyk deleted the feature/python3-support branch April 30, 2020 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants