pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

Minor fixes

Open kxrob opened this issue 3 years ago • 5 comments

kxrob avatar Nov 04 '22 15:11 kxrob

Thanks. Any chance you could split this into one with no functional changes and one where the behavior is changed? Some of the COM ones I'd need to dig deeper in to but some are 100% cosmetic.

mhammond avatar Nov 12 '22 07:11 mhammond

Removed the changes with no functional effect (mainly unused imports and variables)

kxrob avatar Nov 16 '22 18:11 kxrob

Thanks - but I was hoping the changes without functional effect were uploaded as I'd land them - eg, the freeing of a variable isn't controversial so I'd be fine landing that (as well as unused imports which you said you removed). But the ones like the removal of __cmp__ and changing of __nonzero__ to __bool__ might make sense, but I want to tread carefully - eg, the __bool__ one does follow the intent and functionality back in the 2.X days, but now does run the risk of breaking code that's been working in 3.X for many years.

mhammond avatar Nov 17 '22 02:11 mhammond

changes without functional effect were uploaded

I've parked the few de-lints in a new branch, but think its too small and low priority for a PR and will push occasionally with more. (It mainly disturbed getting a clean lint status on edited files - new unused stuff is often an error)

removal of __cmp__

__cmp__ is never used in Py3. The base class HLIPythonObject already provides the appropriate __lt__ and __eq__ regarding self.name, which is enough to support sort in the tree display context. ( @functools.total_ordering would provide full comparisons but not used ... )

changing of __nonzero__ to __bool__

dynamic.CDispatch.__bool__ already exists (via 2to3 2316aef) regarding the same purpose "This class has a __len__ - this is needed so 'if object:' always returns TRUE." It created a problem here where a COM object by chance had a __len__ and zero .Count with surprising behavior under certain circumstances. One indeed doesn't expect a non-true for an existing COM object in if comobj:. So I think overall its more sane to see it as bug - remaining, it would rather add to the incompatibilites with dynamic ( #1943 , #1931 ...) and 2to3s and give raise to more new and lingering surprises vs. very rare chances sb already relied on an odd length check of generated vs dynamic class.

kxrob avatar Nov 18 '22 21:11 kxrob

@kxrob A handful of these changes have been included as part of old code refactoring I've been doing to prepare for type annotations. I think that if you resolve conflicts you'll find this PR to be even smaller than before :)

Avasam avatar Apr 14 '24 00:04 Avasam