-
Notifications
You must be signed in to change notification settings - Fork 825
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
@@ -302,7 +301,7 @@ def RegisterServer( | |||
_remove_key(keyNameRoot + "\\PythonCOMPath") | |||
|
|||
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.frozen
in favor ofgetattr(sys, "frozen", False)
.This is mainly motivated by the side-effect hack importing
win32com
does onpythoncom.frozen
.An alternative is to give more utility to
pythoncom.frozen
by officially making it a wrapper togetattr(sys, "frozen", False)
allowing users to simply usepythoncom.frozen
instead of messing withgetattr
themselves. But I think it's fair to ask if it's pywin32's job to offer a helper property-like attribute to an optionalsys
attribute unrelated to Windows ? (if pywin32 uses its own helper though, that's fine).