-
Notifications
You must be signed in to change notification settings - Fork 842
Stop using (exposing) deprecated Py_FrozenFlag
#2593
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
base: main
Are you sure you want to change the base?
Conversation
55b81a3 to
733d865
Compare
|
|
||
| if addPyComCat is None: | ||
| addPyComCat = pythoncom.frozen == 0 | ||
| addPyComCat = __frozen == False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would've done
| addPyComCat = __frozen == False | |
| addPyComCat = not __frozen |
But since pythoncom.frozen = sys.frozen, and we see above that sys.frozen could be "dll". "dll" != 0.
I don't know if this was an oversight or intended behaviour, so I kept the current behaviour.
f5f985d to
eaea420
Compare
| # This module dynamically re-exports from a C-Extension. | ||
| # `__getattr__() -> Any` prevents checkers attribute access errors | ||
| # without the use of external type stubs. | ||
| # So keep it even if pythoncom.frozen support is removed. | ||
| def __getattr__(name: str) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This incidentally has the exact same benefits as https://github.com/mhammond/pywin32/pull/2418/files#diff-417d6662c94f9f97ab29ec3611822c62e6da513054d38f6dfdc0155fc2f4463b
(which does:
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
def __getattr__(name: str) -> Any: ...)
eaea420 to
c3b7b17
Compare
c3b7b17 to
4e6f444
Compare
This PR aims to stop using
Py_FrozenFlag, solving one of the C API deprecation in #2588The initial version of this PR does so by deprecating
pythoncom.frozenin favor ofgetattr(sys, "frozen", False).This is mainly motivated by the side-effect hack importing
win32comdoes onpythoncom.frozen.An alternative is to give more utility to
pythoncom.frozenby officially making it a wrapper togetattr(sys, "frozen", False)allowing users to simply usepythoncom.frozeninstead of messing withgetattrthemselves. But I think it's fair to ask if it's pywin32's job to offer a helper property-like attribute to an optionalsysattribute unrelated to Windows ? (if pywin32 uses its own helper though, that's fine).