-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Code duplication between stat.py and _stat.c #114081
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
Comments
Perhaps the duplication is intentional, so that a stat module is available even if _stat is not. Even if _stat is always available for CPython, the duplication might be present to cater to non-C implementations. I don't know if the latter is both the reason for duplication and sensible. If so, I think there should be a note saying so. If the duplication is needed, it could be put in the import I would consider separate PRs for handling duplication between the files and fallbacks within _stat, as the back compatibility considerations are different for the two types of changes. |
'Perhaps' is correct; test.test_stat tests everything both with and without _stat.
|
Both implementations are tested, that doesn't necessarily mean that the split is well thought out ;-). A large portion of the duplication is in constant definitions (e.g. UF_SETTABLE). Some of these have a prescribed value according to standards (e.g. To match the implementation pattern for other modules binding existing C APIs we should IMHO drop the python implementation and only keep the C one. That requires discussion outside of the tracker though, and possibly even a PEP. That will have to wait a bit, I don't have the bandwidth for this at this time.
Definitely. |
Option 2 is what usually used in other modules. For end user there should not be difference if they do not use The only difference is when |
@ronaldoussoren specific to #113667 , I noticed that |
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:
Some of these are not really useful, e.g.:
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:
stat.py
_stat.c
and export only those names that are actually available on platformsThe 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).The text was updated successfully, but these errors were encountered: