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

Windows _sys.path file should allow import site #72325

Closed
zooba opened this issue Sep 13, 2016 · 4 comments
Closed

Windows _sys.path file should allow import site #72325

zooba opened this issue Sep 13, 2016 · 4 comments
Assignees
Labels
3.7 (EOL) end of life OS-windows type-bug An unexpected behavior, bug, or error

Comments

@zooba
Copy link
Member

zooba commented Sep 13, 2016

BPO 28138
Nosy @pfmoore, @tds333, @tjguk, @zware, @zooba
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/zooba'
    closed_at = <Date 2016-09-17.19:58:17.338>
    created_at = <Date 2016-09-13.21:11:22.816>
    labels = ['type-bug', '3.7', 'OS-windows']
    title = 'Windows _sys.path file should allow import site'
    updated_at = <Date 2017-03-31.16:36:13.956>
    user = 'https://github.com/zooba'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:13.956>
    actor = 'dstufft'
    assignee = 'steve.dower'
    closed = True
    closed_date = <Date 2016-09-17.19:58:17.338>
    closer = 'steve.dower'
    components = ['Windows']
    creation = <Date 2016-09-13.21:11:22.816>
    creator = 'steve.dower'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 28138
    keywords = []
    message_count = 4.0
    messages = ['276344', '276557', '276564', '276824']
    nosy_count = 6.0
    nosy_names = ['paul.moore', 'tds333', 'tim.golden', 'python-dev', 'zach.ware', 'steve.dower']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue28138'
    versions = ['Python 3.6', 'Python 3.7']

    @zooba
    Copy link
    Member Author

    zooba commented Sep 13, 2016

    Windows's _sys.path file (being renamed from sys.path in b1) currently disable the initial "import site; site.main()" call. However, there are legitimate cases where you may want to opt-in to this while still controlling the search paths.

    We should support "import site" as a line in this file that indicates that Py_NoSite should *not* be set. We deliberately do not want arbitrary code execution from this file - there's a reason it's '.path' and not '.pth'

    (While I or someone else is here, we should also handle blank lines and lines starting with '#' specially, so that files can be formatted more nicely.)

    @zooba zooba added the 3.7 (EOL) end of life label Sep 13, 2016
    @zooba zooba self-assigned this Sep 13, 2016
    @zooba zooba added OS-windows type-bug An unexpected behavior, bug, or error labels Sep 13, 2016
    @tds333
    Copy link
    Mannequin

    tds333 mannequin commented Sep 15, 2016

    But this is nearly the same as a *.pth file.
    Using the same logic and extension then does not confuse more users.

    Why not doing the same as with a .pth file?

    Using something like a _sys.pth file if it is there it will be used for path handling. In all cases on all platforms for interpreter startup.
    (if we will have the embedded interpreter on more platforms)

    @zooba
    Copy link
    Member Author

    zooba commented Sep 15, 2016

    On bpo-28137 I agreed with the proposal to rename to EXENAME.pth, but rather than supporting all of .pth file's syntax we would abort the process on anything we don't like.

    Specifically, we'd allow relative paths, absolute paths, blank lines, comments, and "import site". (The parsing code is written in C and runs before initialization, so we can't exec stuff anyway, but if I had my way I'd ban that from .pth files everywhere.)

    Supporting this on other platforms requires porting the code to Python/getpath.c. I took a quick survey of core devs at the sprints and nobody seemed desperate to have it, but it's something that we can add at any time since it is tied to build/install (rather than anything you'd write in Python code).

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 17, 2016

    New changeset 7b47c98f24da by Steve Dower in branch '3.6':
    Issue bpo-28137: Renames Windows path file to ._pth
    https://hg.python.org/cpython/rev/7b47c98f24da

    @zooba zooba closed this as completed Sep 17, 2016
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life OS-windows type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant