Skip to content

Commit f82f936

Browse files
authored
Remove unused error aliases by assignment (#2269)
1 parent 2e63fe0 commit f82f936

File tree

9 files changed

+17
-19
lines changed

9 files changed

+17
-19
lines changed

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ Coming in build 307, as yet unreleased
2121
* `com/win32com/server/policy.py`
2222
* `win32/Lib/regutil.py`
2323
* `win32/scripts/VersionStamp/vssutil.py`
24-
* Removed the following unused symbols. They were meant to be used as Exceptions, but were accidentally strings (#2270, @Avasam)
24+
* Removed the following unused symbols. They were meant to be used as Exceptions, but were accidentally strings (#2270, #2269, @Avasam)
2525
* `pywin.debugger.debugger.error`
2626
* `pywin.framework.dlgappcore.error`
2727
* `win32com.server.policy.error`
2828
* `regutil.error`
2929
* `win32.scripts.VersionStamp.vssutil.error`
30+
* `win32com.universal.com_error`
31+
* `win32com.client.build.error`
32+
* `win32com.client.genpy.error`
3033
* Add EnumDesktopWindows (#2219, @CristiFati)
3134
* Marked `exc_type` and `exc_traceback` in `win32comext.axscript.client.error.AXScriptException.__init__` as deprecated. (#2236 , @Avasam)
3235
They are now unused and all information is taken from the `exc_value` parameter.

com/win32com/client/build.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
# always render the string perfectly - so just punt and fall-back to a repr()
3030
_makeDocString = repr
3131

32-
error = "PythonCOM.Client.Build error"
33-
3432

3533
class NotSupportedException(Exception):
3634
pass # Raised when we can't support a param type.

com/win32com/client/genpy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
from . import build
2424

25-
error = "makepy.error"
2625
makepy_version = "0.5.01" # Written to generated file.
2726

2827
GEN_FULL = "full"

com/win32com/client/tlbrowse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TLBrowserException(Exception):
1010
"TypeLib browser internal error"
1111

1212

13-
error = TLBrowserException
13+
error = TLBrowserException # Re-exported alias
1414

1515
FRAMEDLG_STD = win32con.WS_CAPTION | win32con.WS_SYSMENU
1616
SS_STD = win32con.WS_CHILD | win32con.WS_VISIBLE

com/win32com/universal.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import pythoncom
66
from win32com.client import gencache
77

8-
com_error = pythoncom.com_error
9-
_univgw = pythoncom._univgw
8+
com_error = pythoncom.com_error # Re-exported alias
109

1110

1211
def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names=None):
@@ -86,15 +85,15 @@ def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names=None):
8685

8786
def _doCreateVTable(iid, interface_name, is_dispatch, method_defs):
8887
defn = Definition(iid, is_dispatch, method_defs)
89-
vtbl = _univgw.CreateVTable(defn, is_dispatch)
90-
_univgw.RegisterVTable(vtbl, iid, interface_name)
88+
vtbl = pythoncom._univgw.CreateVTable(defn, is_dispatch)
89+
pythoncom._univgw.RegisterVTable(vtbl, iid, interface_name)
9190

9291

9392
def _CalcTypeSize(typeTuple):
9493
t = typeTuple[0]
9594
if t & (pythoncom.VT_BYREF | pythoncom.VT_ARRAY):
9695
# It's a pointer.
97-
cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1]
96+
cb = pythoncom._univgw.SizeOfVT(pythoncom.VT_PTR)[1]
9897
elif t == pythoncom.VT_RECORD:
9998
# Just because a type library uses records doesn't mean the user
10099
# is trying to. We need to better place to warn about this, but it
@@ -104,10 +103,10 @@ def _CalcTypeSize(typeTuple):
104103
# warnings.warn("warning: records are known to not work for vtable interfaces")
105104
# except ImportError:
106105
# print("warning: records are known to not work for vtable interfaces")
107-
cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1]
106+
cb = pythoncom._univgw.SizeOfVT(pythoncom.VT_PTR)[1]
108107
# cb = typeInfo.GetTypeAttr().cbSizeInstance
109108
else:
110-
cb = _univgw.SizeOfVT(t)[1]
109+
cb = pythoncom._univgw.SizeOfVT(t)[1]
111110
return cb
112111

113112

@@ -191,8 +190,8 @@ def dispatch(
191190
ob,
192191
index,
193192
argPtr,
194-
ReadFromInTuple=_univgw.ReadFromInTuple,
195-
WriteFromOutTuple=_univgw.WriteFromOutTuple,
193+
ReadFromInTuple=pythoncom._univgw.ReadFromInTuple,
194+
WriteFromOutTuple=pythoncom._univgw.WriteFromOutTuple,
196195
):
197196
"Dispatch a call to an interface method."
198197
meth = self._methods[index]

win32/Lib/sspi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import sspicon
1818
import win32security
1919

20-
error = win32security.error
20+
error = win32security.error # Re-exported alias
2121

2222

2323
class _BaseAuth:

win32/Lib/win32evtlogutil.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import win32evtlog
77
import winerror
88

9-
error = win32api.error # The error the evtlog module raises.
10-
9+
error = win32api.error # Re-exported alias (The error the evtlog module raises).
1110
langid = win32api.MAKELANGID(win32con.LANG_NEUTRAL, win32con.SUBLANG_NEUTRAL)
1211

1312

win32/Lib/win32pdhutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import win32pdh
2626

27-
error = win32pdh.error
27+
error = win32pdh.error # Re-exported alias
2828

2929
# Handle some localization issues.
3030
# see http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q287/1/59.asp&NoWebContent=1

win32/Lib/win32serviceutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import win32service
1818
import winerror
1919

20-
error = RuntimeError
20+
error = RuntimeError # Re-exported alias
2121

2222

2323
# Returns the full path to an executable for hosting a Python service - typically

0 commit comments

Comments
 (0)