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

Start pyc file lock the file #77632

Closed
Jean-LouisTamburini mannequin opened this issue May 9, 2018 · 7 comments
Closed

Start pyc file lock the file #77632

Jean-LouisTamburini mannequin opened this issue May 9, 2018 · 7 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@Jean-LouisTamburini
Copy link
Mannequin

Jean-LouisTamburini mannequin commented May 9, 2018

BPO 33451
Nosy @brettcannon, @pfmoore, @ncoghlan, @tjguk, @ericsnowcurrently, @berkerpeksag, @zware, @eryksun, @zooba, @miss-islington
PRs
  • bpo-33451: Close .pyc files before calling PyEval_EvalCode() #7884
  • [3.7] bpo-33451: Close pyc files before calling PyEval_EvalCode() (GH-7884) #7888
  • [3.6] bpo-33451: Close pyc files before calling PyEval_EvalCode() (GH-7884) #7889
  • Files
  • dummy.py
  • 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 = None
    closed_at = <Date 2018-08-14.13:16:53.566>
    created_at = <Date 2018-05-09.20:43:58.880>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7']
    title = 'Start pyc file lock the file'
    updated_at = <Date 2018-08-14.13:16:53.564>
    user = 'https://bugs.python.org/Jean-LouisTamburini'

    bugs.python.org fields:

    activity = <Date 2018-08-14.13:16:53.564>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-08-14.13:16:53.566>
    closer = 'berker.peksag'
    components = ['Interpreter Core']
    creation = <Date 2018-05-09.20:43:58.880>
    creator = 'Jean-Louis Tamburini'
    dependencies = []
    files = ['47592']
    hgrepos = []
    issue_num = 33451
    keywords = ['patch']
    message_count = 7.0
    messages = ['316330', '316667', '316832', '316843', '320346', '320349', '323518']
    nosy_count = 11.0
    nosy_names = ['brett.cannon', 'paul.moore', 'ncoghlan', 'tim.golden', 'eric.snow', 'berker.peksag', 'zach.ware', 'eryksun', 'steve.dower', 'miss-islington', 'Jean-Louis Tamburini']
    pr_nums = ['7884', '7888', '7889']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33451'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @Jean-LouisTamburini
    Copy link
    Mannequin Author

    Jean-LouisTamburini mannequin commented May 9, 2018

    Python v3.6.4:d48eceb
    Windows 10.0.16299

    I search on Internet and I don't find why Python Interpreter (v3.6.4) do that. With python 2.7, I don't have this "problem".

    When I launch script like :
    c:\Python364\python.exe compile.py
    While the execution, I can rename/modify the file "compile.py".

    But, when I compile the file to .pyc (with py_compile with an another script), and I launch the pyc like :
    c:\Python364\python.exe dummy.pyc
    While the execution, I CAN'T rename/modify the file because is locked by Python Interpreter.

    It's normal ?

    @Jean-LouisTamburini Jean-LouisTamburini mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 9, 2018
    @Jean-LouisTamburini
    Copy link
    Mannequin Author

    Jean-LouisTamburini mannequin commented May 15, 2018

    Same for python v3.6.5:f59c0932b4

    @brettcannon
    Copy link
    Member

    There's no specific reason as to why that would happen as no files are kept open after importing is finished.

    @eryksun
    Copy link
    Contributor

    eryksun commented May 16, 2018

    In Python/pythonrun.c, PyRun_SimpleFileExFlags() reopens the PYC file in binary mode, passes it to run_pyc_file(), and only closes it after executing the script. The file should instead be closed in run_pyc_file(), before calling PyEval_EvalCode().

    @eryksun eryksun added 3.7 (EOL) end of life 3.8 only security fixes labels May 16, 2018
    @ncoghlan
    Copy link
    Contributor

    New changeset ea73775 by Nick Coghlan (Zackery Spytz) in branch 'master':
    bpo-33451: Close pyc files before calling PyEval_EvalCode() (GH-7884)
    ea73775

    @miss-islington
    Copy link
    Contributor

    New changeset 56aaef0 by Miss Islington (bot) in branch '3.7':
    bpo-33451: Close pyc files before calling PyEval_EvalCode() (GH-7884)
    56aaef0

    @berkerpeksag
    Copy link
    Member

    All PRs have been merged (commit message from the 3.6 branch doesn't listed here but PR 7889 has been merged in 8f8ad2c) Closing this as 'fixed'. Please reopen if this issue needs to stay open.

    @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 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants