forked from mhammond/pywin32
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythoncom.py
More file actions
29 lines (24 loc) · 1.1 KB
/
Copy pathpythoncom.py
File metadata and controls
29 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Magic utility that "redirects" to pythoncomXX.dll
from typing import Any
import pywintypes
pywintypes.__import_pywin32_system_module__("pythoncom", globals())
# 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 an empty stub behind `if TYPE_CHECKING` if pythoncom.frozen support is removed.
def __getattr__(name: str) -> Any:
if name == "frozen":
import sys
import warnings
warnings.warn(
f"`pythoncom.frozen` used to expose `Py_FrozenFlag` from the C API. "
+ "`Py_FrozenFlag` is deprecated since Python 3.12. "
+ "Ever since pywin32 b200, loading the `win32com` module has silently "
+ "been replacing `pythoncom.frozen` with `sys.frozen`. "
+ 'Use `getattr(sys, "frozen", False)` directly instead.',
DeprecationWarning,
stacklevel=2,
)
return getattr(sys, "frozen", False)
else:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")