Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WIP] bpo-42260: Rewrite getpath.c in Python#23169

Closed
vstinner wants to merge 2 commits into
python:mainpython/cpython:mainfrom
vstinner:getpath_pyCopy head branch name to clipboard
Closed

[WIP] bpo-42260: Rewrite getpath.c in Python#23169
vstinner wants to merge 2 commits into
python:mainpython/cpython:mainfrom
vstinner:getpath_pyCopy head branch name to clipboard

Conversation

@vstinner

@vstinner vstinner commented Nov 5, 2020

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

https://bugs.python.org/issue42260

@vstinner

vstinner commented Nov 5, 2020

Copy link
Copy Markdown
Member Author

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

vstinner commented Nov 5, 2020

Copy link
Copy Markdown
Member Author

* 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
Copy Markdown
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
Copy Markdown

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.