-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Add python 3.11 support #514
Conversation
c36cf45
to
ab52404
Compare
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #514 +/- ##
==========================================
+ Coverage 73.22% 73.41% +0.19%
==========================================
Files 296 296
Lines 25837 26001 +164
Branches 3650 4401 +751
==========================================
+ Hits 18918 19088 +170
+ Misses 5834 5826 -8
- Partials 1085 1087 +2 |
4a54ecf
to
12258bf
Compare
enaml/core/code_generator.py
Outdated
@@ -383,6 +430,9 @@ def try_squash_raise(self): | |||
the code, rather than any function called by the code. | |||
|
|||
""" | |||
if PY311: | |||
yield | |||
return # TODO: Is this still possible? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using TryBegin and TryEnd pseudo instructions this should be feasible. I can give it a try but I may prioritize getting the pegen branch in first since we need it too
enaml/core/code_generator.py
Outdated
""" Make a function from a code object on the TOS. | ||
|
||
""" | ||
if not PY311: | ||
self.load_const(name) | ||
self.code_ops.append( # TOS -> qual_name -> code -> defaults | ||
bc.Instr("MAKE_FUNCTION", n_defaults), # TOS -> func |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under 3.11 MAKE_FUNCTION does not take the number of default anymore but a code (see https://docs.python.org/3.11/library/dis.html#opcode-MAKE_FUNCTION). This probably explain your issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this has been the case ever since 2.7, anyways there is only one call to make_function with defaults and it happens to be 0x01
so that is why it worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it could be the origin of your default argument issue. I will have to look elsewhere (possibly in the C helpers)
Could you rebase this on main now that #474 is in ? (Cherry picking your changes might be easier) Also I apologize for the last two commits, I forgot to switch branch. |
So I have an implementation for try_squash_raise. I just need to audit the usages to ensure we never have a try/except inside the try_squash_raise. I will look at the kwarg default next. |
0becad2
to
e025f05
Compare
Thanks for rebasing. I will push my solution for try_squah_raise later today. The issue with function default lies in CPython itself. PyEval_EvalCodeEx started using _PyFunction_FromConstructor in 3.11 but this function does not pass the defaults found in the frame constructor... I will open an issue on CPython repo. |
CPython issue reported at python/cpython#101072 |
Still blocked on the CPython issue, the PR I made is pending review. |
The cpython issue has been closed and the fix will be in 3.11.2 ! I will try to have everything ready by then. |
3.11.2 is available on GHA (I misremembered the release date), let's see if it works ! |
Looks like it still is using 3.11.1 |
Yes and I find it extremely annoying ! We will have to wait a tiny bit longer it seems. |
7d1fe92
to
eee53e7
Compare
Thanks for your work @frmdstryr |
Thank you! |
This updates the code generator/compiler to work with Python 3.11, it builds on the pegen branch because the main branch just fails due to invalid col offsets in the ast.
try_squash_raise
can still be implemented?On a positive note I get about a 10-15% speedup with this on enaml-web :).