Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable warnings as errors when testing and migrate away from deprecated import methods #130

Closed
wants to merge 7 commits into from

Conversation

altendky
Copy link

@altendky altendky commented Jun 4, 2024

It turns out that my import failure noted over in jaraco/keyring#683 is triggered by the fact we (not keyring) run our tests (using keyring and thus pywin32-ctypes) with warnings reported as errors. This results in pywin32-ctypes failing to be imported due to some import related warnings.

These are taken from a PR in my fork where CI is running (without approval).

https://github.com/altendky/pywin32-ctypes/actions/runs/9375227229/job/25812921472?pr=1#step:5:163

  File "D:\a\pywin32-ctypes\pywin32-ctypes\pywin32-tests\test_pywintypes.py", line 18, in <module>
    from win32ctypes import pywin32
  File "D:\a\pywin32-ctypes\pywin32-ctypes\win32ctypes\pywin32\__init__.py", line 9, in <module>
    from win32ctypes.pywin32 import win32api
  File "D:\a\pywin32-ctypes\pywin32-ctypes\win32ctypes\pywin32\win32api.py", line 9, in <module>
    from win32ctypes.core import (
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
ImportWarning: BackendLoader.exec_module() not found; falling back to load_module()

I'll keep this updated as I understand this better.

Looks like the fallback that is happening is to BackendLoader.load_module().

def load_module(self, fullname):
module = importlib.import_module(self.redirect_module)
sys.modules[fullname] = module
return module

https://docs.python.org/3.12/library/importlib.html#importlib.abc.Loader.load_module

Deprecated since version 3.4: The recommended API for loading a module is exec_module() (and create_module()). Loaders should implement it instead of load_module(). The import machinery takes care of all the other responsibilities of load_module() when exec_module() is implemented.

There is a warning about datetime utc tz aware etc etc that haas addressed in scalative/haas@59809b1 but is not yet released.
https://github.com/altendky/pywin32-ctypes/actions/runs/9376291633/job/25815980893?pr=1#step:5:96

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

@altendky altendky changed the title enable warnings as errors when testing enable warnings as errors when testing and migrate away from deprecated import methods Jun 5, 2024
@itziakos
Copy link
Member

itziakos commented Jun 8, 2024

Thanks @altendky I have added an issue to update the deprecated code.

@altendky
Copy link
Author

Thanks for getting a change in. I missed that you had done it separately or I would have been excited sooner. :]

@altendky altendky closed this Aug 13, 2024
@itziakos
Copy link
Member

No worries, I will upload a new wheel to pypi this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants