Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ As of build 305, installation .exe files have been deprecated; see
Coming in build 312, as yet unreleased
--------------------------------------

* The following classes will now use the correct subclass name in `repr`: (mhammond#2570, [@Avasam][Avasam])
* `pywin.tools.browser.HLIPythonObject`
* `win32com.client.VARIANT`
* `win32com.client.build.MapEntry`
* `win32com.server.exception.COMException`
* `win32comext.axdebug.debugger.ModuleTreeNode`
* `win32comext.axscript.client.pyscript.NamedScriptAttribute`
* `win32comext.axscript.client.error.AXScriptException`
* `win32pdhquery.QueryError`
* `win32rcparser.StringDef`

Build 311, released 2025/07/14
------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/tools/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __eq__(self, other):

def __repr__(self):
return (
f"{self.__class__.__name__}(name={self.name!r}, object={self.myobject!r})"
f"{self.__class__.__name__}(myobject={self.myobject!r}, name={self.name!r})"
)

def GetText(self):
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def __bool__(self):

# A very simple VARIANT class. Only to be used with poorly-implemented COM
# objects. If an object accepts an arg which is a simple "VARIANT", but still
# is very pickly about the actual variant type (eg, isn't happy with a VT_I4,
# is very picky about the actual variant type (eg, isn't happy with a VT_I4,
# which it would get from a Python integer), you can use this to force a
# particular VT.
class VARIANT:
Expand All @@ -700,4 +700,4 @@ def _del_value(self):
value = property(_get_value, _set_value, _del_value)

def __repr__(self):
return f"win32com.client.VARIANT({self.varianttype!r}, {self._value!r})"
return f"{self.__class__.__module__}.{self.__class__.__name__}({self.varianttype!r}, {self._value!r})"
4 changes: 2 additions & 2 deletions com/win32com/client/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class NotSupportedException(Exception):


class MapEntry:
"Simple holder for named attibutes - items in a map."
"""Simple holder for named attributes - items in a map."""

def __init__(
self,
Expand Down Expand Up @@ -99,7 +99,7 @@ def __init__(

def __repr__(self):
return (
"MapEntry(dispid={s.dispid}, desc={s.desc}, names={s.names}, doc={s.doc!r}, "
"{s.__class__.__name__}(dispid={s.dispid}, desc={s.desc}, names={s.names}, doc={s.doc!r}, "
"resultCLSID={s.resultCLSID}, resultDocumentation={s.resultDocumentation}, "
"wasProperty={s.wasProperty}, hidden={s.hidden}"
).format(s=self)
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/server/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
pythoncom.com_error.__init__(self, scode, self.description, None, -1)

def __repr__(self):
return f"{self.__class__.__name__}(scode={self.scode!r}, desc={self.description!r})"
return f"{self.__class__.__name__}(description={self.description!r}, scode={self.scode!r})"


def IsCOMException(t=None):
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/axdebug/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, module):
self.cont = codecontainer.SourceModuleContainer(module)

def __repr__(self):
return f"<ModuleTreeNode wrapping {self.module}>"
return f"<{self.__class__.__name__} wrapping {self.module}>"

def Attach(self, parentRealNode):
self.realNode.Attach(parentRealNode)
Expand Down
2 changes: 1 addition & 1 deletion win32/Lib/win32pdhquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,6 @@ def __init__(self, query: BaseQuery):
self.query = query

def __repr__(self):
return f"<Query Error in {self.query!r}>"
return f"<{self.__class__.__name__} in {self.query!r}>"

__str__ = __repr__
2 changes: 1 addition & 1 deletion win32/Lib/win32rcparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(self, id, idNum, value):
self.value = value

def __repr__(self):
return f"StringDef({self.id!r}, {self.idNum!r}, {self.value!r})"
return f"{self.__class__.__name__}({self.id!r}, {self.idNum!r}, {self.value!r})"


class RCParser:
Expand Down