Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Nov 5, 2020

  • Add _getpath Python module and _cgetpath C module
  • Py_SetPath() no longer computes the path configuration.

https://bugs.python.org/issue42260

@vstinner
Copy link
Member Author

vstinner commented Nov 5, 2020

The PR is still a draft.

Modules/getpath.c is reimplemented in pure Python as Lib/_getpath.py. The module is frozen by "make regen-importlib" and run by by pyinit_main():

PyRun_SimpleString("import _getpath; _getpath.main()");

I kept Modules/getpath.c to ease development, but it will be fully removed in the final patch.

There are likely bugs in my conversion from getpath.c (C) to _getpath.py (Python).

The new Python module gets a companion _cgetpath: a C extension to expose functions needed by _getpath (Python).

Code size: 1623 lines for getpath.c (C) => 654 lines for _getpath.py (Python), and way simpler string manipulation: 2.5x smaller code.

Right now, 4 tests are still failing (test_embed, test_sys, test_gdb and a 4th that I forgot!).

@vstinner
Copy link
Member Author

vstinner commented Nov 5, 2020

* Add _getpath Python module and _cgetpath C module
* Py_SetPath() no longer computes the path configuration.
* _PyErr_SetFromPyStatus() now raises SystemExit if the status is an
  exit code.
Also move PathConfig class
@vstinner
Copy link
Member Author

Remaining issue: test_init_read_set() fails. The error on Windows is different than the error on Linux/macOS.

Windows:

-  'base_executable': 'D:\\a\\cpython\\cpython\\PCbuild\\amd64\\_testembed.exe',
+  'base_executable': 'my_executable',

Linux/macOS:


   'module_search_paths': ['/opt/python-dev/lib/python310.zip',
-                          'Lib',
?                           ^ ^

+                          'test_path_insert1',
?                           ^^^^^^^^^^ ^^^^^^

+                          '/Users/runner/work/cpython/cpython/Lib',
-                          'build/lib.macosx-10.15-x86_64-3.10-pydebug'],
?                                                                      -

+                          '/Users/runner/work/cpython/cpython/build/lib.macosx-10.15-x86_64-3.10-pydebug',
?                           +++++++++++++++++++++++++++++++++++

+                          'test_path_append'],

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Dec 26, 2020
@vstinner vstinner closed this Sep 21, 2021
@vstinner vstinner deleted the getpath_py branch September 21, 2021 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants