Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

sys.path[0] Is Set Differently From the Rest of sys.path #109853

Open
@ericsnowcurrently

Description

@ericsnowcurrently

Feature or enhancement

Currentlysys.path[0] is set bypymain_run_python() (in Modules/main.c). This happensafterpymain_init(), which initializes the runtime, including the rest ofsys.path (via getpath.py and site.py). This makes it harder to reason about and introduces extra complexity for subinterpreters. (Seegh-109793 andgh-109794.)

We should consider calculatingsys.path[0] and setting it to its ownPyConfig field via getpath.py, when the rest of the basesys.path is calculated. We may need a later check to verify that there is a matching importer, aspymain_run_python() does. (FWIW, it isn't clear that there's any value to storing thesys.path[0] value on the global_PyPathConfig.)

Also, we currently wait to actually setsys.path[0] (for the main interpreter) until after the readline/rlcompleter modules are imported inpymain_run_python(). We'd need to factor that in.

CC@zooba,@vstinner,@ncoghlan

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp