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

Support Python 3.10 #1022

Closed
rchen152 opened this issue Oct 6, 2021 · 0 comments · Fixed by #1176
Closed

Support Python 3.10 #1022

rchen152 opened this issue Oct 6, 2021 · 0 comments · Fixed by #1176
Assignees
Labels
cat: core core language and typing features enhancement

Comments

@rchen152
Copy link
Contributor

rchen152 commented Oct 6, 2021

Python 3.10.0 came out yesterday.

@rchen152 rchen152 added enhancement cat: core core language and typing features labels Oct 6, 2021
rchen152 added a commit that referenced this issue Oct 6, 2021
Generated by following the mostly automated steps at the beginning of
https://github.com/google/pytype/blob/master/docs/developers/python_version_upgrades.md.
With this, we actually get useful test results rather than a bunch of
key errors for missing Python 3.10 magic numbers.

For #1022.
rchen152 added a commit that referenced this issue Oct 7, 2021
Generated by following the mostly automated steps at the beginning of https://github.com/google/pytype/blob/master/docs/developers/python_version_upgrades.md. With this, we actually get useful test results rather than a bunch of key errors for missing Python 3.10 magic numbers. For #1022.

Resolves #1023

PiperOrigin-RevId: 401326143
rchen152 added a commit that referenced this issue Feb 17, 2022
* Change builtins.NotImplementedType to _NotImplementedType to match typeshed.
* Add Concatenate, ParamSpec, TypeAlias, TypeGuard, and is_typeddict to typing.

These changes get pytype.load_pytd_test and typeshed's pytype_test passing in
3.10.

For #1022.

PiperOrigin-RevId: 429376959
@rchen152 rchen152 self-assigned this Feb 17, 2022
rchen152 added a commit that referenced this issue Feb 18, 2022
The script missed an opcode (RERAISE) whose index changed in 3.10.

Technically speaking, we should be using different class definitions for
RERAISE in pyc/opcodes.py depending on the target version, but using the 3.10
definition in older versions doesn't seem to cause any issues, so it's simpler
to just always use the newest definition.

For #1022.

PiperOrigin-RevId: 429463279
rchen152 added a commit that referenced this issue Feb 18, 2022
This bug manifested in tests as an IndexError on the
`op.arg = op.pretty_arg = offset_to_index[op.arg]` line in pyc/opcodes.py.
Skimming through the Python changelog
(https://docs.python.org/3/whatsnew/changelog.html), I found this entry:

bpo-27129: The bytecode interpreter uses instruction, rather byte, offsets
internally. This reduces the number of EXTENDED_ARG instructions needed and
streamlines instruction dispatch a bit.

The corresponding CPython commit
(python/cpython@fcb55c0)
helpfully includes a change to the stdlib `dis` library that shows how to
adjust oparg calculation to account for this change.

For #1022.

PiperOrigin-RevId: 429488804
rchen152 added a commit that referenced this issue Mar 1, 2022
This brings down the number of 3.10 test failures from 106 to 87.

For #1022.

PiperOrigin-RevId: 431061841
rchen152 added a commit that referenced this issue Mar 23, 2022
* Handles a change in how function annotations are stored.
* Adds the NO_NEXT flag to the new RERAISE opcode.
* Implements NOP. This opcode was present in 3.9 as well but seems to have gone
  unused until 3.10.

These fixes reduce the number of tracebacks in our test logs from 966 to 320
(and the remaining ones seem to be assertion errors for test failures).

For #1022.

PiperOrigin-RevId: 436792541
rchen152 added a commit that referenced this issue Mar 25, 2022
… parser.

In our line number calculations, we were skipping the first delta, leading to
our line numbers sometimes being off by one.

This fix brings down the test failure count from 320 to 69.

For #1022.

PiperOrigin-RevId: 437330907
rchen152 added a commit that referenced this issue Mar 29, 2022
* Copies some logic for adjusting line deltas from the CPython source. I don't
  understand it, but it works?
* Fixes an expected error message in the pyi parser test. The pre-3.10 error
  message was better IMO, but the error message comes from the stdlib ast
  parser, so we don't have control over it.

We now have just 26 test failures in 8 test files left.

For #1022.

PiperOrigin-RevId: 437374111
rchen152 added a commit that referenced this issue Mar 31, 2022
…s allowed.

The immediate reason for this change is to fix a test that was failing in 3.10
because we were failing to log [not-supported-yet] for
typing_extensions.TypeGuard. I took the opportunity to simplify some things in
typing_overlay and typing_extensions_overlay to make future development easier
and enable us to log more accurate and helpful error messages.

For #1022.

PiperOrigin-RevId: 438436286
rchen152 added a commit that referenced this issue Apr 1, 2022
Updates some tests in cases where it was obvious to me that the problem was in
the test and not the functionality under test.

Only 21 failures in 5 test modules left.

For #1022.

PiperOrigin-RevId: 438635996
rchen152 added a commit that referenced this issue Apr 6, 2022
* tests/test_errors1: All that needed to be done here was adjusting some of the
  expected error counts and messages. While I was in the file, I also changed
  some unnecessary usages of InferWithErrors to CheckWithErrors.
* constant_folding_test: In 3.10, LIST_APPEND, MAP_ADD, and DICT_UPDATE are
  used to construct large constant lists and dicts, so constant_folding needs
  to know what to do with them.

Only four failures in three test files left!

For #1022.

PiperOrigin-RevId: 439487010
rchen152 added a commit that referenced this issue Apr 6, 2022
The last few test failures were due to the line numbers of RETURN_VALUE opcodes
changing. The only real bugs were in pytype's handling of function type
comments, and since (1) no one should have any reason to use function type
comments anymore and (2) the failures are in what look like pretty uncommon
edge cases, I just skipped those tests in 3.10.

I also updated the upper version bound and fixed a type annotation so that the
GitHub pytype check runs successfully in 3.10.

For #1022.

PiperOrigin-RevId: 439905120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: core core language and typing features enhancement
Projects
None yet
1 participant