Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Code duplication between stat.py and _stat.c #114081

Open
@ronaldoussoren

Description

@ronaldoussoren

There's code duplication between stat.py and _stat.c and a large subset of that is in definitions that are at least in theory platform dependent.

The C file also contains a lot a local fallback definitions of constants, like:

#ifndef S_IROTH
#  define S_IROTH 00004
#endif

Some of these are not really useful, e.g.:

#ifndef S_IFDOOR
#  define S_IFDOOR 0
#endif

We don't do this in other modules, and these fallback definition make it harder to determine which constants are relevant for the current platform.

Proposal:

  1. Remove the definition of platform constants from stat.py
  2. Remove fallback definitions in _stat.c and export only those names that are actually available on platforms
  3. Add explicit tests for those constants that we require to be available on all platforms

The 2nd bullet might break backward compatibility by removing flags on platforms that don't have them (in particular flags like UF_NODUMP that are likely only available on BSDs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions