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

Python 3 fixes - fix invalid ABCMeta comparison #6251

Merged
merged 2 commits into from Jul 28, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Jul 27, 2018

Calls to sorted() would fail in Py3 with some of the engine code, because Py3 doesn't allow relational comparisons for objects that don't implement __lt__, unlike Py2. It was complaining ABCMeta < ABCMeta is an invalid comparison.

Solution is to set the key as hash function. I believe this is how Py2 was doing this implicitly.

cc @mateor - much better solution than what we discussed IRL.

@@ -24,7 +24,7 @@ def table(self):
def constraint(self):
"""Returns the typeconstraint for the symbol table"""
# NB Sort types so that multiple calls get the same tuples.
symbol_table_types = sorted(set(self.table().values()))
symbol_table_types = sorted(set(self.table().values()), key=hash)

This comment has been minimized.

@stuhood

stuhood Jul 27, 2018

Member

Is it possible to sort these by "fully qualified string name" or something? I'm worried that the hash will not be stable across hosts (maybe it already wasn't).

@stuhood stuhood merged commit 80ef528 into pantsbuild:master Jul 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:py3-fixes_abc-meta-comparison branch Jul 28, 2018

stuhood added a commit that referenced this pull request Jul 28, 2018

Python 3 fixes - fix base folder (#6252)
Everything should be green with Py2 and Py3, excluding the native engine issue discussed on Slack + pending PRs #6251, #6245, and #6244.

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - fix invalid ABCMeta comparison (pantsbuild#6251)
Calls to `sorted()` would fail in Py3 with some of the engine code, because Py3 doesn't allow relational comparisons for objects that don't implement `__lt__`, unlike Py2. It was complaining `ABCMeta < ABCMeta` is an invalid comparison.

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - fix base folder (pantsbuild#6252)
Everything should be green with Py2 and Py3, excluding the native engine issue discussed on Slack + pending PRs pantsbuild#6251, pantsbuild#6245, and pantsbuild#6244.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment