From fcb43e678e0458ec2a9f52af87f82ddfe597599c Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 18:39:41 -0400 Subject: [PATCH 1/7] enable warnings as errors when testing --- pywin32-tests/test_pywintypes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pywin32-tests/test_pywintypes.py b/pywin32-tests/test_pywintypes.py index 81dab38..8a93717 100644 --- a/pywin32-tests/test_pywintypes.py +++ b/pywin32-tests/test_pywintypes.py @@ -11,6 +11,9 @@ import faulthandler import datetime import time +import warnings + +warnings.simplefilter("error") from win32ctypes import pywin32 from win32ctypes.pywin32.pywintypes import error From 7469cea8f324a8f378468ae2cc4b4a6bc8e52baf Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 20:00:15 -0400 Subject: [PATCH 2/7] let's try _something_ --- win32ctypes/core/__init__.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/win32ctypes/core/__init__.py b/win32ctypes/core/__init__.py index eb6a401..5f3e2db 100644 --- a/win32ctypes/core/__init__.py +++ b/win32ctypes/core/__init__.py @@ -21,15 +21,24 @@ _backend = 'cffi' -class BackendLoader(Loader): +# class BackendLoader(Loader): - def __init__(self, redirect_module): - self.redirect_module = redirect_module +# def __init__(self, redirect_module): +# self.redirect_module = redirect_module - def load_module(self, fullname): - module = importlib.import_module(self.redirect_module) - sys.modules[fullname] = module - return module +# def create_module(self, spec): +# return importlib.import_module(self.redirect_module) + +# importlib.util.module_from_spec(spec) +# return None + +# def exec_module(self, module): + + +# def load_module(self, fullname): +# module = importlib.import_module(self.redirect_module) +# sys.modules[fullname] = module +# return module class BackendFinder(MetaPathFinder): @@ -46,8 +55,11 @@ def find_spec(self, fullname, path, target=None): redirected = f'win32ctypes.core.ctypes.{module_name}' else: redirected = f'win32ctypes.core.cffi.{module_name}' - loader = BackendLoader(redirected) - return importlib.machinery.ModuleSpec(module_name, loader) + spec = importlib.util.find_spec(redirected) + spec.name = module_name + return spec + # loader = BackendLoader(redirected) + # return importlib.machinery.ModuleSpec(module_name, loader) else: return None From bc35cb4a9813fae20147242d5ffac5e7633ab5a8 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 20:02:07 -0400 Subject: [PATCH 3/7] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb9bb33..675ef50 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,7 @@ on: jobs: tests: strategy: + fail-fast: false matrix: python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] os: [windows-2019] From 3081d5795c666b3fa244f5ce1a3047ff418a2a22 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 20:04:07 -0400 Subject: [PATCH 4/7] Update test.yml --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 675ef50..01f24d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,12 +9,10 @@ on: jobs: tests: strategy: - fail-fast: false matrix: python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] os: [windows-2019] runs-on: ${{ matrix.os }} - needs: code-lint steps: - name: Checkout repository uses: actions/checkout@v4 From 649bc7af3a74a0201fd7e605247b50116afabe8b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 20:05:17 -0400 Subject: [PATCH 5/7] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01f24d5..b328e27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,7 @@ on: jobs: tests: strategy: + fail-fast: false matrix: python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] os: [windows-2019] From 8ef6b93f2384398b2eb6426bb979464636fb5951 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 20:43:41 -0400 Subject: [PATCH 6/7] Update __init__.py --- win32ctypes/core/__init__.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/win32ctypes/core/__init__.py b/win32ctypes/core/__init__.py index 5f3e2db..1fdfccf 100644 --- a/win32ctypes/core/__init__.py +++ b/win32ctypes/core/__init__.py @@ -21,24 +21,17 @@ _backend = 'cffi' -# class BackendLoader(Loader): +class BackendLoader(Loader): -# def __init__(self, redirect_module): -# self.redirect_module = redirect_module + def __init__(self, redirect_module): + self.redirect_module = redirect_module -# def create_module(self, spec): -# return importlib.import_module(self.redirect_module) - -# importlib.util.module_from_spec(spec) -# return None - -# def exec_module(self, module): - - -# def load_module(self, fullname): -# module = importlib.import_module(self.redirect_module) -# sys.modules[fullname] = module -# return module + def create_module(self, spec): + # TODO: this seems wrong, but let's see the behavior + return importlib.import_module(self.redirect_module) + + def exec_module(self, module): + pass class BackendFinder(MetaPathFinder): @@ -55,11 +48,11 @@ def find_spec(self, fullname, path, target=None): redirected = f'win32ctypes.core.ctypes.{module_name}' else: redirected = f'win32ctypes.core.cffi.{module_name}' - spec = importlib.util.find_spec(redirected) - spec.name = module_name - return spec - # loader = BackendLoader(redirected) - # return importlib.machinery.ModuleSpec(module_name, loader) + # spec = importlib.util.find_spec(redirected) + # spec.name = module_name + # return spec + loader = BackendLoader(redirected) + return importlib.machinery.ModuleSpec(module_name, loader) else: return None From 745a52c0702227089f669ca2c10622730cb5662a Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Tue, 4 Jun 2024 20:58:08 -0400 Subject: [PATCH 7/7] Update __init__.py --- win32ctypes/core/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/win32ctypes/core/__init__.py b/win32ctypes/core/__init__.py index 1fdfccf..48d52e2 100644 --- a/win32ctypes/core/__init__.py +++ b/win32ctypes/core/__init__.py @@ -28,6 +28,7 @@ def __init__(self, redirect_module): def create_module(self, spec): # TODO: this seems wrong, but let's see the behavior + # please do tell me the right way :] return importlib.import_module(self.redirect_module) def exec_module(self, module): @@ -48,9 +49,6 @@ def find_spec(self, fullname, path, target=None): redirected = f'win32ctypes.core.ctypes.{module_name}' else: redirected = f'win32ctypes.core.cffi.{module_name}' - # spec = importlib.util.find_spec(redirected) - # spec.name = module_name - # return spec loader = BackendLoader(redirected) return importlib.machinery.ModuleSpec(module_name, loader) else: