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

Incorrect logging in importlib when '.pyc' file creation fails #79205

Closed
qagren mannequin opened this issue Oct 19, 2018 · 4 comments
Closed

Incorrect logging in importlib when '.pyc' file creation fails #79205

qagren mannequin opened this issue Oct 19, 2018 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@qagren
Copy link
Mannequin

qagren mannequin commented Oct 19, 2018

BPO 35024
Nosy @brettcannon, @ncoghlan, @ericsnowcurrently, @pablogsal, @miss-islington, @tirkarthi, @qagren, @iritkatriel
PRs
  • bpo-35024: Remove redundant and possibly incorrect verbose message after writing '.pyc' #9998
  • 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 2020-08-18.18:42:10.091>
    created_at = <Date 2018-10-19.04:00:41.592>
    labels = ['type-bug', 'library']
    title = "Incorrect logging in importlib when '.pyc' file creation fails"
    updated_at = <Date 2020-08-18.18:42:10.089>
    user = 'https://github.com/qagren'

    bugs.python.org fields:

    activity = <Date 2020-08-18.18:42:10.089>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-08-18.18:42:10.091>
    closer = 'brett.cannon'
    components = ['Library (Lib)']
    creation = <Date 2018-10-19.04:00:41.592>
    creator = 'qagren'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35024
    keywords = ['patch']
    message_count = 4.0
    messages = ['328029', '328586', '375569', '375624']
    nosy_count = 8.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'eric.snow', 'pablogsal', 'miss-islington', 'xtreak', 'qagren', 'iritkatriel']
    pr_nums = ['9998']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35024'
    versions = ['Python 3.6']

    @qagren
    Copy link
    Mannequin Author

    qagren mannequin commented Oct 19, 2018

    Hi,

    This is the first issue I submit so please correct me if I do anything wrong.

    Description of the issue:
    imporlib logs 'wrote <path to .pyc file>' even when file creation fails with OSError (for lack of write persmission for example)

    Reproducing the bug in Python 3.6 on ubuntu 16.04:

    cd /home/quentin/tmp
    mkdir __pycache__
    chmod -R -w __pycache__
    echo '1 + 1' > spam.py
    python -vv -c'import spam' 2>&1 | grep '__pycache__/spam'

    Output:
    # could not create '/home/quentin/tmp/pycache/spam.cpython-36.pyc': PermissionError(13, 'Permission denied')
    # wrote '/home/quentin/tmp/pycache/spam.cpython-36.pyc'

    Reason:
    SourceFileLoader.set_data() silences OSError raised by _write_atomic (importlib/_bootstrap_external.py line 875)
    Then SourceLoader.get_code() does not see that something went awry and logs file creation (same file, line 789)

    If it is worth fixing I would be glad to contribute a patch, but would probably need a little guidance.

    @qagren qagren mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 19, 2018
    @miss-islington
    Copy link
    Contributor

    New changeset 9e14e49 by Miss Islington (bot) (Quentin Agren) in branch 'master':
    bpo-35024: Remove redundant and possibly incorrect verbose message after writing '.pyc' (GH-9998)
    9e14e49

    @iritkatriel
    Copy link
    Member

    This seems resolved, can it be closed?

    @brettcannon
    Copy link
    Member

    It looks like it! Thanks, Irit!

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants