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

bpo-38109: Add missing constants to Lib/stat.py #16665

Merged
merged 2 commits into from Oct 10, 2019
Merged

Conversation

rlamy
Copy link
Contributor

@rlamy rlamy commented Oct 8, 2019

Lib/stat.py was missing the constants S_IFDOOR, S_IFPORT, S_IFWHT as well as the related S_IS... functions. This is a port of https://bitbucket.org/pypy/pypy/commits/f245f35c61eb.

https://bugs.python.org/issue38109

@brandtbucher
Copy link
Member

brandtbucher commented Oct 8, 2019

Thanks for your time @rlamy, and welcome to CPython! 😎

CC @tiran

Copy link
Member

@brandtbucher brandtbucher left a comment

This looks like a good change to me! It should also have a NEWS entry, though. Just something like:

Add missing :data:`stat.S_IFDOOR`, :data:`stat.S_IFPORT`, :data:`stat.S_IFWHT`,
:func:`stat.S_ISDOOR`, :func:`stat.S_ISPORT`, and :func:`stat.S_ISWHT` values to
the Python implementation of :mod:`stat`.

@vstinner
Copy link
Member

vstinner commented Oct 8, 2019

I can reproduce https://bugs.python.org/issue38109 with this example:

import sys
sys.modules.pop('stat', None)
sys.modules['_stat'] = None
import stat
print(stat.S_ISDOOR(123))

Output:

AttributeError: module 'stat' has no attribute 'S_ISDOOR'

It works as expected with this PR:

False

Copy link
Member

@vstinner vstinner left a comment

LGTM.

Would you mind to add a NEWS entry using the blurb tool? You can use: #16665 (review)

@vstinner vstinner merged commit 7bb1431 into python:master Oct 10, 2019
@miss-islington
Copy link
Contributor

miss-islington commented Oct 10, 2019

Thanks @rlamy for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 10, 2019
Add missing stat.S_IFDOOR, stat.S_IFPORT, stat.S_IFWHT,
stat.S_ISDOOR, stat.S_ISPORT, and stat.S_ISWHT values to
the Python implementation of the stat module.
(cherry picked from commit 7bb1431)

Co-authored-by: Ronan Lamy <ronan.lamy@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 10, 2019
Add missing stat.S_IFDOOR, stat.S_IFPORT, stat.S_IFWHT,
stat.S_ISDOOR, stat.S_ISPORT, and stat.S_ISWHT values to
the Python implementation of the stat module.
(cherry picked from commit 7bb1431)

Co-authored-by: Ronan Lamy <ronan.lamy@gmail.com>
vstinner pushed a commit that referenced this pull request Oct 10, 2019
Add missing stat.S_IFDOOR, stat.S_IFPORT, stat.S_IFWHT,
stat.S_ISDOOR, stat.S_ISPORT, and stat.S_ISWHT values to
the Python implementation of the stat module.
(cherry picked from commit 7bb1431)

Co-authored-by: Ronan Lamy <ronan.lamy@gmail.com>
vstinner pushed a commit that referenced this pull request Oct 10, 2019
Add missing stat.S_IFDOOR, stat.S_IFPORT, stat.S_IFWHT,
stat.S_ISDOOR, stat.S_ISPORT, and stat.S_ISWHT values to
the Python implementation of the stat module.
(cherry picked from commit 7bb1431)

Co-authored-by: Ronan Lamy <ronan.lamy@gmail.com>
@brandtbucher
Copy link
Member

brandtbucher commented Oct 10, 2019

Congrats on your first CPython contribution @rlamy! 🍾

Looking forward to seeing more from you in the future.

@vstinner
Copy link
Member

vstinner commented Oct 10, 2019

Ronan already helped CPython in the past :-)

commit 569ff4fbbc4cd0589c369519745d8d17bf3094b0
Author: Brett Cannon <brett@python.org>
Date:   Fri Jan 11 18:09:25 2013 -0500

    Issue #15031: Refactor some code in importlib pertaining to validating
    and compiling bytecode.
    
    Thanks to Ronan Lamy for pointing the redundancy and taking an initial
    stab at the refactor (as did Nick Coghlan).

commit 1e331560eea62c78ec189f2b72b59864ee315ddc
Author: Brett Cannon <brett@python.org>
Date:   Mon Jul 2 14:35:34 2012 -0400

    Closes #15030: Make importlib.abc.PyPycLoader respect the new .pyc
    file size header field.
    
    Thanks to Marc Abramowitz and Ronan Lamy for helping out with various
    parts of the patch.

commit ea0b8239401123fa7f41c74f6fc9ded1cf74088a
Author: Brett Cannon <brett@python.org>
Date:   Fri Jun 15 20:00:53 2012 -0400

    Issue #14938: importlib.abc.SourceLoader.is_package() now takes the
    module name into consideration when determining whether a module is a
    package or not. This prevents importing a module's __init__ module
    directly and having it considered a package, which can lead to
    duplicate sub-modules.
    
    Thanks to Ronan Lamy for reporting the bug.

@brandtbucher
Copy link
Member

brandtbucher commented Oct 10, 2019

Ah, my bad. Github’s "First-time Contributor" badge led me to believe otherwise.

Thanks for the clarification @vstinner!

@vstinner
Copy link
Member

vstinner commented Oct 10, 2019

Ah, my bad. Github’s "First-time Contributor" badge led me to believe otherwise.

Hehe. Python only migrated to Git and GitHub 2 years ago. Previously, we only kept track of the authors in the commit message, not in the author field.

@brandtbucher
Copy link
Member

brandtbucher commented Oct 10, 2019

sigh I guess in the future I’ll have to check Misc/ACKS too... Ronan is in there.

jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
Add missing stat.S_IFDOOR, stat.S_IFPORT, stat.S_IFWHT,
stat.S_ISDOOR, stat.S_ISPORT, and stat.S_ISWHT values to
the Python implementation of the stat module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants