Skip to content

Commit 0e61536

Browse files
authored
Merge branch 'master' into empty_message
2 parents fcd5d4d + 02d1ec1 commit 0e61536

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.0.17 (2024-10-31)
4+
5+
* Handle PermissionError in fallback code for old import name [#182](https://github.com/Kludex/python-multipart/pull/182).
6+
37
## 0.0.16 (2024-10-27)
48

59
* Add dunder attributes to `multipart` package [#177](https://github.com/Kludex/python-multipart/pull/177).

fuzz/fuzz_form.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ def parse_form_urlencoded(fdp: EnhancedDataProvider) -> None:
2929

3030

3131
def parse_multipart_form_data(fdp: EnhancedDataProvider) -> None:
32-
header = {"Content-Type": "multipart/form-data; boundary=--boundary"}
33-
parse_form(header, io.BytesIO(fdp.ConsumeRandomBytes()), on_field, on_file)
32+
boundary = "boundary"
33+
header = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
34+
body = (
35+
f"--{boundary}\r\n"
36+
f"Content-Type: multipart/form-data; boundary={boundary}\r\n\r\n"
37+
f"{fdp.ConsumeRandomString()}\r\n"
38+
f"--{boundary}--\r\n"
39+
)
40+
parse_form(header, io.BytesIO(body.encode("latin1", errors="ignore")), on_field, on_file)
3441

3542

3643
def TestOneInput(data: bytes) -> None:

multipart/__init__.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

88
for p in sys.path:
99
file_path = Path(p, "multipart.py")
10-
if file_path.is_file():
11-
spec = importlib.util.spec_from_file_location("multipart", file_path)
12-
assert spec is not None, f"{file_path} found but not loadable!"
13-
module = importlib.util.module_from_spec(spec)
14-
sys.modules["multipart"] = module
15-
assert spec.loader is not None, f"{file_path} must be loadable!"
16-
spec.loader.exec_module(module)
17-
break
10+
try:
11+
if file_path.is_file():
12+
spec = importlib.util.spec_from_file_location("multipart", file_path)
13+
assert spec is not None, f"{file_path} found but not loadable!"
14+
module = importlib.util.module_from_spec(spec)
15+
sys.modules["multipart"] = module
16+
assert spec.loader is not None, f"{file_path} must be loadable!"
17+
spec.loader.exec_module(module)
18+
break
19+
except PermissionError:
20+
pass
1821
else:
1922
warnings.warn("Please use `import python_multipart` instead.", PendingDeprecationWarning, stacklevel=2)
2023
from python_multipart import *

python_multipart/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__author__ = "Andrew Dunham"
33
__license__ = "Apache"
44
__copyright__ = "Copyright (c) 2012-2013, Andrew Dunham"
5-
__version__ = "0.0.16"
5+
__version__ = "0.0.17"
66

77
from .multipart import (
88
BaseParser,

0 commit comments

Comments
 (0)