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

os.stat / os.lstat always present, but code checks hastattr(os, 'stat') / hasattr(os, 'lstat') #79983

Closed
asottile mannequin opened this issue Jan 21, 2019 · 5 comments
Closed
Labels
3.8 only security fixes stdlib Python modules in the Lib dir

Comments

@asottile
Copy link
Mannequin

asottile mannequin commented Jan 21, 2019

BPO 35802
Nosy @gpshead, @giampaolo, @asottile
PRs
  • bpo-35802: Clean up code which checked presence of os.{stat,lstat,chmod} #11643
  • bpo-35802: Clean up code which checked presence of os.{stat,lstat,chmod} #11643
  • 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 2019-02-25.22:55:35.604>
    created_at = <Date 2019-01-21.21:42:34.213>
    labels = ['3.8', 'library']
    title = "os.stat / os.lstat always present, but code checks hastattr(os, 'stat') / hasattr(os, 'lstat')"
    updated_at = <Date 2019-02-26.00:07:17.042>
    user = 'https://github.com/asottile'

    bugs.python.org fields:

    activity = <Date 2019-02-26.00:07:17.042>
    actor = 'giampaolo.rodola'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-02-25.22:55:35.604>
    closer = 'Anthony Sottile'
    components = ['Library (Lib)']
    creation = <Date 2019-01-21.21:42:34.213>
    creator = 'Anthony Sottile'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35802
    keywords = ['patch', 'patch']
    message_count = 5.0
    messages = ['334182', '334184', '334226', '334229', '336584']
    nosy_count = 3.0
    nosy_names = ['gregory.p.smith', 'giampaolo.rodola', 'Anthony Sottile']
    pr_nums = ['11643', '11643']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue35802'
    versions = ['Python 3.8']

    @asottile
    Copy link
    Mannequin Author

    asottile mannequin commented Jan 21, 2019

    Unless I'm reading incorrectly:

    #define OS_STAT_METHODDEF \
    {"stat", (PyCFunction)(void(*)(void))os_stat, METH_FASTCALL|METH_KEYWORDS, os_stat__doc__},

    #define OS_LSTAT_METHODDEF \
    {"lstat", (PyCFunction)(void(*)(void))os_lstat, METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__},

    @asottile asottile mannequin added 3.8 only security fixes stdlib Python modules in the Lib dir labels Jan 21, 2019
    @asottile
    Copy link
    Mannequin Author

    asottile mannequin commented Jan 21, 2019

    looks true for os.chmod as well:

    #define OS_CHMOD_METHODDEF \
    {"chmod", (PyCFunction)(void(*)(void))os_chmod, METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__},

    @gpshead
    Copy link
    Member

    gpshead commented Jan 22, 2019

    I suspect these conditionals are very old and came from times when we supported some platforms that did not have these APIs.

    Are they present on all CPython supported platforms today?

    Windows is probably the only one left to verify.

    BSD/Linux/Un*xes and modern macOS are POSIX.

    macOS <= 9 (classic) has long since died.

    @asottile
    Copy link
    Mannequin Author

    asottile mannequin commented Jan 22, 2019

    yep! did my due diligence there, you can check my work on #11643

    all platforms have these functions since posixmodule.c is always compiled and the functions in question are not guarded by preprocessor directives in any way

    @asottile asottile mannequin closed this as completed Feb 25, 2019
    @giampaolo
    Copy link
    Contributor

    A BB failed. Looks like it's unrelated with this change:
    https://buildbot.python.org/all/#/builders/99/builds/2198

    @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.8 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants