-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: support for python 3.11 #31
Conversation
Thanks! I was going to do this once 3.11 was closer, it's nice to have some help. Please put the new logic inside Also please add thorough tests for 3.11. |
I get the same test failures locally using the latest 3.11 installed by |
I tested my commit with python 3.11.0a3 and it passed the tests (tox -e py311). |
Yeah they passed for me locally too (before and after my changes) until I reinstalled 3.11. |
the generated bytecode has changed: test script: import dis
def foo():
@deco1
@deco2()
class test:
pass
dis.dis(foo) python 3.11.0a3
python 3.11.0a5
What was previously a CALL_FUNCTION is now PRECALL_FUNCTION & CALL. But it is questionable if it makes sense, because this might change again till the release of 3.11. |
I'd be happy with a first PR that:
Followup PRs to fix decorators and |
I was able to detect the decorator, but that is enough for today. |
We are rebuilding all RPM packages in Fedora with the new Python 3.11. I can confirm that the problem is still there with Python 3.11a6 with this patch applied. The result is:
|
@15r10nk just reiterating that the decorator and qualnames are low priority. |
The relevant part of Python 3.11 changelog: https://docs.python.org/3.11/whatsnew/3.11.html#cpython-bytecode-changes |
I took a look at it and there are new CACHE instructions added, which change the current handling of decorators. I also have problems to understand some of the test cases (the long running especially) and I am not sure which I can ignore. |
Then skip or xfail the failing decorator tests in 3.11.
Skip the failing |
Decorators should work again (was not so difficult in the end),
|
The log is saying that it failed to find a node for this instruction:
That's the @cell_magic
def eye(self, _line, cell):
if not self.server_url:
server.db = Database(self.db_url)
server.Function = server.db.Function
server.Call = server.db.Call
server.Session = server.db.Session
Thread(
target=run_server,
args=(
self.port,
self.bind_host,
self.show_server_output,
),
).start() Everything seems to agree correctly that that's on line 105, except for the instruction |
Your error looks also like a bug in 3.11 for me, but I don't know if we get the same errors. My looks like this:
If I understand the test correctly the problem is that it does not find any bytecode instruction for this ast node. |
I'm looking at the CI logs here, I didn't run it myself. But yes, the sample files were probably just listed in different orders, if you checked the ipython sample first it would probably give you the same error.
That's correct. Look for places where it checks that the name starts with |
I was able to fix the line number mismatch:
However I don't understand why my change fixes the problem ... And it seems that the line numbers are not the actual problem. I suspect that the positions in the instructions are not taken directly from AST ranges (which would break my approach). I don't know if this is intentional or a bug in python. |
python/cpython@d48848c83e this commit changed the line number for the LOAD_METHOD instruction (file compile.c function maybe_optimize_method_call). That is the reason why I am not able to find the ast node and the only(...) call fails in the test. |
Created this two cpython issues which are related to this: |
Just a note that the first beta is out and no new features should land in Python 3.11. |
Hello, 2nd beta of Python 3.11 is out. When I tried to build executing with this PR the test_decorator failed with:
|
I was wondering if it would be possible to do a partial merge that does not include a fix for the decorators, as suggested earlier. My reason is that I have currently many tests that I must skip in friendly-traceback for Python 3.11 and I would like to figure out if these will work with the proposed fix, or if they require further changes to executing. |
* This provides a new implementation, which uses co_positions() to lookup the ast node. * It has a simpler implementation and better performance. * Some limitations in the unit tests are removed for 3.11. * support for `and` and `or` * no ambiguities for generators
I think I fixed all the issues you mentioned. Let me know if I forgot something. |
…of a inner loop
…or name mangeling
… is part of the control flow
`find_node` raised an error while checking if a CALL operation is a decorator application.
I let it run over 428514 python files to find the last issues. I think it is getting pretty stable. |
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.
Also need to install .[tests]
in .github/...yml
instead of the manually listed requirements.
Huge thank you for this massive contribution! Merging now but going to test it with other packages before I release. |
and
andor