mhammond / pywin32

Python for Windows (pywin32) Extensions
5.01k stars 792 forks source link

deduplicate afxres #2177

Closed Avasam closed 6 months ago

Avasam commented 7 months ago

Something I noticed. Pythonwin/pywin/mfc/afxres.py and win32/Lib/afxres.py are perfectly identical and I don't immediately see a technical reason for it. So this PR attempts to deduplicate the modules whilst keeping backwards compatibility. Imports in pywin have also been updated.

mhammond commented 6 months ago

An alternative here would be to treat the pythonwin one as canonical and later emit a deprecation warning for the "global" top-level import. This module really only makes sense in the context of MFC, and every import other than the "resource parser" is in pythonwin.

Avasam commented 6 months ago

That makes a lot of sense and I applied your suggestion

and later emit a deprecation warning

I don't see an issue emitting one now, deprecation warnings are made to warn ahead of time. But there's always https://docs.python.org/3/library/exceptions.html#PendingDeprecationWarning. Although even that says:

This class is rarely used as emitting a warning about a possible upcoming deprecation is unusual, and DeprecationWarning is preferred for already active deprecations.