Skip to content

Commit

Permalink
Remove unused error aliases by assignment (#2269)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Jun 4, 2024
1 parent 2e63fe0 commit f82f936
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
5 changes: 4 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ Coming in build 307, as yet unreleased
* `com/win32com/server/policy.py`
* `win32/Lib/regutil.py`
* `win32/scripts/VersionStamp/vssutil.py`
* Removed the following unused symbols. They were meant to be used as Exceptions, but were accidentally strings (#2270, @Avasam)
* Removed the following unused symbols. They were meant to be used as Exceptions, but were accidentally strings (#2270, #2269, @Avasam)
* `pywin.debugger.debugger.error`
* `pywin.framework.dlgappcore.error`
* `win32com.server.policy.error`
* `regutil.error`
* `win32.scripts.VersionStamp.vssutil.error`
* `win32com.universal.com_error`
* `win32com.client.build.error`
* `win32com.client.genpy.error`
* Add EnumDesktopWindows (#2219, @CristiFati)
* Marked `exc_type` and `exc_traceback` in `win32comext.axscript.client.error.AXScriptException.__init__` as deprecated. (#2236 , @Avasam)
They are now unused and all information is taken from the `exc_value` parameter.
Expand Down
2 changes: 0 additions & 2 deletions com/win32com/client/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
# always render the string perfectly - so just punt and fall-back to a repr()
_makeDocString = repr

error = "PythonCOM.Client.Build error"


class NotSupportedException(Exception):
pass # Raised when we can't support a param type.
Expand Down
1 change: 0 additions & 1 deletion com/win32com/client/genpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from . import build

error = "makepy.error"
makepy_version = "0.5.01" # Written to generated file.

GEN_FULL = "full"
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/tlbrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TLBrowserException(Exception):
"TypeLib browser internal error"


error = TLBrowserException
error = TLBrowserException # Re-exported alias

FRAMEDLG_STD = win32con.WS_CAPTION | win32con.WS_SYSMENU
SS_STD = win32con.WS_CHILD | win32con.WS_VISIBLE
Expand Down
17 changes: 8 additions & 9 deletions com/win32com/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import pythoncom
from win32com.client import gencache

com_error = pythoncom.com_error
_univgw = pythoncom._univgw
com_error = pythoncom.com_error # Re-exported alias


def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names=None):
Expand Down Expand Up @@ -86,15 +85,15 @@ def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names=None):

def _doCreateVTable(iid, interface_name, is_dispatch, method_defs):
defn = Definition(iid, is_dispatch, method_defs)
vtbl = _univgw.CreateVTable(defn, is_dispatch)
_univgw.RegisterVTable(vtbl, iid, interface_name)
vtbl = pythoncom._univgw.CreateVTable(defn, is_dispatch)
pythoncom._univgw.RegisterVTable(vtbl, iid, interface_name)


def _CalcTypeSize(typeTuple):
t = typeTuple[0]
if t & (pythoncom.VT_BYREF | pythoncom.VT_ARRAY):
# It's a pointer.
cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1]
cb = pythoncom._univgw.SizeOfVT(pythoncom.VT_PTR)[1]
elif t == pythoncom.VT_RECORD:
# Just because a type library uses records doesn't mean the user
# is trying to. We need to better place to warn about this, but it
Expand All @@ -104,10 +103,10 @@ def _CalcTypeSize(typeTuple):
# warnings.warn("warning: records are known to not work for vtable interfaces")
# except ImportError:
# print("warning: records are known to not work for vtable interfaces")
cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1]
cb = pythoncom._univgw.SizeOfVT(pythoncom.VT_PTR)[1]
# cb = typeInfo.GetTypeAttr().cbSizeInstance
else:
cb = _univgw.SizeOfVT(t)[1]
cb = pythoncom._univgw.SizeOfVT(t)[1]
return cb


Expand Down Expand Up @@ -191,8 +190,8 @@ def dispatch(
ob,
index,
argPtr,
ReadFromInTuple=_univgw.ReadFromInTuple,
WriteFromOutTuple=_univgw.WriteFromOutTuple,
ReadFromInTuple=pythoncom._univgw.ReadFromInTuple,
WriteFromOutTuple=pythoncom._univgw.WriteFromOutTuple,
):
"Dispatch a call to an interface method."
meth = self._methods[index]
Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/sspi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sspicon
import win32security

error = win32security.error
error = win32security.error # Re-exported alias


class _BaseAuth:
Expand Down
3 changes: 1 addition & 2 deletions win32/Lib/win32evtlogutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import win32evtlog
import winerror

error = win32api.error # The error the evtlog module raises.

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


Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/win32pdhutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import win32pdh

error = win32pdh.error
error = win32pdh.error # Re-exported alias

# Handle some localization issues.
# see http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q287/1/59.asp&NoWebContent=1
Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/win32serviceutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import win32service
import winerror

error = RuntimeError
error = RuntimeError # Re-exported alias


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

0 comments on commit f82f936

Please sign in to comment.