-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import of GitHub PR #587: Add minimum changes required for py3.8 support
#587 Merge 917097e into 549363b GITHUB_PR_BODY=This is a continuation of @pganssle's work on #559 Beyond just making it compile, this also adds some of the newer VM and marshaling stuff such as positional only arguments. It also addresses and adds tests for a 3.6 feature that allows the line number to opcode table (`lnotab`) to be non monotonic. After this the remaining failing tests are: ``` ** pytype.vm_test ** pytype.tests.py3.test_variable_annotations ** pytype.tools.xref.indexer_test ** pytype.tests.py3.test_typing_namedtuple ** pytype.tests.test_decorators ** pytype.tests.test_with ** pytype.tests.test_exceptions ** pytype.tests.test_flow ** pytype.tests.py3.test_coroutine ** pytype.tests.py3.test_annotations ** pytype.tests.py3.test_stdlib ** pytype.tests.test_builtins1 ** pytype.tests.test_basic ``` I'll take a look at them later or someone else can carry through with those. Either way I'd like to land this first to make the reviews manageable. ----- As @pganssle noted on their PR, there is some weird behavior going on with the tests that causes them to fail but not produce any output in the console or the log files. Upon further investigation this was caused by a segmentation fault in `cfg.cc`. In Python 3.8, `PyStructSequence_InitType` was changed so that it errors out if a type with a reference count greater than 0 is passed in: https://github.com/python/cpython/blame/3.8/Objects/structseq.c#L396-L400 This error was being silently swallowed because we were just assuming that `PyStructSequence_InitType` was running successfully. The problem was we were using `PyObject_HEAD_INIT` which [initializes the refcount to 1](https://github.com/python/cpython/blob/35b8a4da7494cd51f3edeaa07764dd8f14bac0bf/Include/object.h#L83-L85). With this fixed there should now be actual output from the test runs so hopefully this work should be easier to continue by others. ---- ### Notes on the workflow As Paul mentioned, the workflow on the open-source end of pytype is pretty bespoke and not too friendly. I would recommend using `tox` and separating out the `googletest` based C/C++ tests from the Python ones. The `build_scripts` folder has a lot of magic that masks the details of how the build system works underneath. CMake is currently being used to build the extension, run Python tests and run C++ tests. Building and testing C++ is CMake's forte but there's a lot of code to handle the discovery and running of Python tests. This might have been done to keep symmetry with the `py_test` build rule internally but it is completely alien to most open-source Python developers. Instead, using something like the builtin `unittest` module or `pytest` to drive the Python tests would be a more comfortable experience. For example, one of the issues I had was figuring out how to make CMake use my locally compiled Python 3.8 build. Passing custom arguments to CMake is nearly impossible due to the build_scripts. I'd recommend this, if you're on a debian based distro, add the deadsnakes ppa or similar and use: ```shell sudo apt install python3.7 python3.7-dev python3.7-venv python3.7 -m venv venv . ./venv/bin/activate python3.7 build_scripts/build.py python3.7 build_scripts/run_tests.py ``` Swap out 3.7 for whatever host Python version you want to test with. Next, for debugging issues like the mysterious failing tests without output, the most important file is `out/ninja.log`. This actually shows the commands being invoked to run the tests. The exact incantation seems to be: `TYPESHED_HOME=/home/aaskar/workspace/pytype/typeshed /home/aaskar/workspace/pytype/venv/bin/python3.8 -B /home/aaskar/workspace/pytype/build_scripts/test_module.py pytype.tests.test_basic -o /home/aaskar/workspace/pytype/out/pytype/tests/test_basic.log -P /home/aaskar/workspace/pytype/out -s -p` Failing tests can also be run with unittest instead of the custom runner for a workflow where you don't have to repeatedly check a log file after making changes like so: `TYPESHED_HOME=$PWD/typeshed python3.8 -m unittest pytype.tools.traces.traces_test` PiperOrigin-RevId: 313493580
- Loading branch information
1 parent
f56f465
commit 39afb06
Showing
12 changed files
with
176 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.