From ca52662eda368bd61fbb9508bfaffb0fc4af6028 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Thu, 31 Oct 2024 08:04:56 +0100 Subject: [PATCH 1/2] Handle PermissionError in fallback code for old import name (#182) --- multipart/__init__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/multipart/__init__.py b/multipart/__init__.py index cdc0154..67f0e5b 100644 --- a/multipart/__init__.py +++ b/multipart/__init__.py @@ -7,14 +7,17 @@ for p in sys.path: file_path = Path(p, "multipart.py") - if file_path.is_file(): - spec = importlib.util.spec_from_file_location("multipart", file_path) - assert spec is not None, f"{file_path} found but not loadable!" - module = importlib.util.module_from_spec(spec) - sys.modules["multipart"] = module - assert spec.loader is not None, f"{file_path} must be loadable!" - spec.loader.exec_module(module) - break + try: + if file_path.is_file(): + spec = importlib.util.spec_from_file_location("multipart", file_path) + assert spec is not None, f"{file_path} found but not loadable!" + module = importlib.util.module_from_spec(spec) + sys.modules["multipart"] = module + assert spec.loader is not None, f"{file_path} must be loadable!" + spec.loader.exec_module(module) + break + except PermissionError: + pass else: warnings.warn("Please use `import python_multipart` instead.", PendingDeprecationWarning, stacklevel=2) from python_multipart import * From 616b81e72fe67ce67e332c446513ef89b9d816dc Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Thu, 31 Oct 2024 08:07:53 +0100 Subject: [PATCH 2/2] Version 0.0.17 (#183) --- CHANGELOG.md | 4 ++++ python_multipart/__init__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56dbb3f..9a6fbba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.0.17 (2024-10-31) + +* Handle PermissionError in fallback code for old import name [#182](https://github.com/Kludex/python-multipart/pull/182). + ## 0.0.16 (2024-10-27) * Add dunder attributes to `multipart` package [#177](https://github.com/Kludex/python-multipart/pull/177). diff --git a/python_multipart/__init__.py b/python_multipart/__init__.py index a2d50d2..be8327f 100644 --- a/python_multipart/__init__.py +++ b/python_multipart/__init__.py @@ -2,7 +2,7 @@ __author__ = "Andrew Dunham" __license__ = "Apache" __copyright__ = "Copyright (c) 2012-2013, Andrew Dunham" -__version__ = "0.0.16" +__version__ = "0.0.17" from .multipart import ( BaseParser,