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

Adds Python3.8 support #24

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

insignification
Copy link

Based on PR #21, adds python3.8 support (previously part of the 'fix2' PR)

insignification and others added 8 commits December 10, 2019 23:48
(overrides previous fix, as merging them would be too complex and
unneeded)
I was not able to get it to happen for pretty huge functions (much much
larger than the ones in the test), though, so there's a good chance it's
unreachable.
(This was originally in the second PR, but since you want to take this
one first, I think it's a good commit to add here, since it's relevant
to this change and would make diffing against future PRs easier)
Added 4 tests, 3 currently disabled (pre-existing issues, especially on
pypy).
(The new test helps test functionality that needs special attention at
least on py38)
@insignification
Copy link
Author

Details:

  1. Python 3.8 adds another parameter to CodeType constructor, but also luckily adds a replace method to make code construction more version-independent.
  2. Python 3.8 removes SETUP_LOOP, so in this situation, we rely on FOR_ITER and POP_TOP instead.

@snoack
Copy link
Owner

snoack commented Dec 15, 2019

Can you rebase this pull request? (Or alternatively merging master back into your branch does as well.)

@insignification
Copy link
Author

FYI the "Various minor crash/etc fixes" one doesn't fail checks, probably best to skip this PR and merge that. (No point in trying to analyze an already fixed bug)

@snoack
Copy link
Owner

snoack commented Dec 15, 2019

So you are suggesting to merge #22 before merging this PR? Fine with me, just rebase (or merge) #22 against the current master, and I have a look.

except AttributeError:
pass
return code.replace(co_code=codestring) # new in 3.8+
except:
Copy link
Owner

Choose a reason for hiding this comment

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

Please no bare expects, this should be expect AttributeError.

Copy link
Author

Choose a reason for hiding this comment

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

True, I'll fix


return size

def _get_instructions_size(ops):
Copy link
Owner

Choose a reason for hiding this comment

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

It seems you did a mistake during merge. This function, and the one above are now defined twice, see below.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, merge failure. I see you added flake8 which catches this, I'll fix it (in the other PR).

@@ -63,6 +63,18 @@ def func():
assert func() == 0


def test_jump_out_of_loop_and_survive():
Copy link
Owner

Choose a reason for hiding this comment

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

I might (likely) miss something here, but how is this new test related to adding support for Python 3.8?

@@ -34,6 +34,8 @@ def __init__(self):
self.have_argument = dis.HAVE_ARGUMENT
self.jump_unit = 1

self.has_loop_blocks = 'SETUP_LOOP' in dis.opmap
Copy link
Owner

Choose a reason for hiding this comment

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

I'm wondering if we should rather check for 'SETUP_LOOP' in dis.opmap in place than aliasing the result of this check here? It doesn't seem to save much writing, neither does it seem to improve performance.

Copy link
Author

Choose a reason for hiding this comment

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

I think it's cleaner, and it's far from a sole occurrence - see the later PRs which add more such checks, some (I think) used more than once.

@insignification
Copy link
Author

Yes, let's focus on #22 instead of this PR. It's provided here so you can review it as a "step" separate from #22, but it's evidently missing some fixes included in #22 and there's no reason to start digging which fix is needed.

(And I don't see a reason to remove the py38 changes from the #22 PR before merging it, you've already reviewed them here, it'd just be extra busywork)

It's already merged against master, and I'll fix it up per your comments and flake8 shortly

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.

None yet

2 participants