Skip to content

Commit 13e5ca8

Browse files
committed
Docstrings, typos and formatting
1 parent d3b2133 commit 13e5ca8

6 files changed

Lines changed: 20 additions & 21 deletions

File tree

CHANGELOG.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Release 1.4 (not released yet)
1515
==============================
1616

1717
* feat: Hardened (and faster) header validation.
18-
* change: Dropped support for Python 3.8 and 3.8 (both EOL)
18+
* change: Dropped support for Python 3.8 and 3.9 (both EOL)
1919
* change: Raise more helpful :exc:`ParserStateError` instead of implicit
2020
:exc:`AssertionError` or :exc:`TypeError` when the parser is used
2121
incorrectly.
2222
* change: Enforce `part_limit` (128 by default) for url-encoded data in
23-
`parse_form_data()`. This is consistend with the handling of multipart
24-
and an improtant safeguard against denial of service.
23+
`parse_form_data()`. This is consistent with the handling of multipart
24+
and an important safeguard against denial of service.
2525
* change: New strict-mode check to reject extremely large boundaries.
26-
* build: Change default brach to `main`.
26+
* build: Change default branch to `main`.
2727

2828

2929
Release 1.3

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2010-2025, Marcel Hellkamp
1+
Copyright (c) 2010-2026, Marcel Hellkamp
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Features
4444
* 100% test coverage with test data from actual browsers and HTTP clients.
4545
* High throughput and low latency (see `benchmarks <https://github.com/defnull/multipart_bench>`_).
4646
* Predictable memory and disk resource consumption via fine grained limits.
47-
* Strict mode: Spent less time parsing malicious or broken inputs.
47+
* Strict mode: Spend less time parsing malicious or broken inputs.
4848

4949
Scope and compatibility
5050
=======================

docs/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Features and Scope
4747
* 100% test coverage with test data from actual browsers and HTTP clients.
4848
* High throughput and low latency (see `benchmarks <https://github.com/defnull/multipart_bench>`_).
4949
* Predictable memory and disk resource consumption via fine grained limits.
50-
* Strict mode: Spent less time parsing malicious or broken inputs.
50+
* Strict mode: Spend less time parsing malicious or broken inputs.
5151

5252
**Scope:** All parsers in this module implement ``multipart/form-data`` as defined by HTML5_
5353
and RFC7578_, supporting all modern browsers or HTTP clients in use today.
@@ -65,8 +65,8 @@ Installation
6565

6666
``pip install multipart`` or ``uv add multipart``
6767

68-
Table of Content
69-
================
68+
Table of Contents
69+
=================
7070

7171
.. toctree::
7272
:maxdepth: 2

docs/usage.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ based environment:
5555
else:
5656
print("Form text field without a filename")
5757
58-
elif event: # Non-empty batearray
58+
elif event: # Non-empty bytearray
5959
print(f"Received {len(event)} bytes of data")
6060
6161
else: # None
@@ -128,7 +128,7 @@ Buffered Parser
128128
The :class:`MultipartParser` parser is the lazy blocking cousin of
129129
:class:`PushMultipartParser`. It can read from a blocking byte stream (e.g.
130130
``environ["wsgi.input"]``) and emits :class:`MultipartPart` instances that are
131-
either memory- or disk-buffered debending on size.
131+
either memory- or disk-buffered depending on size.
132132

133133
The main benefit is that you no longer have to assemble the payload chunks of
134134
each segment yourself. It is still a streaming parser, which means you can start
@@ -156,7 +156,7 @@ Here is a basic example for a typical WSGI_ application:
156156
elif part.size < 1024:
157157
print(f"{part.name}: Text field ({part.value!r})")
158158
else:
159-
print(f"{part.name}: Test field, but too big to print :/")
159+
print(f"{part.name}: Text field, but too big to print :/")
160160
161161
# Free up resources after use
162162
for part in parser.parts():
@@ -167,7 +167,7 @@ Results are cached, so you can iterate or call :meth:`MultipartParser.get` or
167167

168168
Do not forget to :meth:`close() <MultipartPart.close>` all parts after use to
169169
remove unused temporary files quicker and avoid :exc:`ResourceWarning`.
170-
Framework developers may want to add hooks to automatically frees up resources
170+
Framework developers may want to add hooks to automatically free up resources
171171
after the request ended.
172172

173173

@@ -236,4 +236,3 @@ to do its job. Do not forget to add proper error handling.
236236
environ = dict(os.environ.items())
237237
environ['wsgi.input'] = sys.stdin.buffer
238238
forms, files = multipart.parse_form_data(environ)
239-

multipart.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
77
https://multipart.readthedocs.io/
88
9-
Copyright (c) 2010-2025, Marcel Hellkamp
9+
Copyright (c) 2010-2026, Marcel Hellkamp
1010
License: MIT (see LICENSE file)
1111
"""
1212

13-
1413
__author__ = "Marcel Hellkamp"
1514
__version__ = "1.4.0-dev"
1615
__license__ = "MIT"
@@ -40,7 +39,7 @@
4039
Tuple,
4140
List,
4241
Callable,
43-
Awaitable
42+
Awaitable,
4443
)
4544

4645
from urllib.parse import unquote_plus as _unquote_plus
@@ -479,7 +478,6 @@ def parse(self, chunk: t_ByteString) -> Generator[t_ParserEvent, None, None]:
479478
offset = 0
480479

481480
while True:
482-
483481
if self._state is _PREAMBLE:
484482
# Scan for first delimiter (CRLF prefix is optional here)
485483
index = buffer.find(delimiter[2:], offset)
@@ -541,7 +539,6 @@ def parse(self, chunk: t_ByteString) -> Generator[t_ParserEvent, None, None]:
541539
break # wait for more data
542540

543541
elif self._state is _BODY:
544-
545542
# Ensure there is enough data in buffer to fit a delimiter
546543
if offset + d_len + 2 > bufferlen:
547544
break # wait for more data
@@ -890,6 +887,9 @@ def __init__(
890887
data as needed to return the next part. Results are cached and the same
891888
part can be requested multiple times without extra cost.
892889
890+
Note that you should either set `partsize_limit` or `disk_limit` depending
891+
on your specific requirements. Both are unlimited by default.
892+
893893
:param stream: A readable byte stream or any other object that implements
894894
a :meth:`read(size) <io.BufferedIOBase.read>` method.
895895
:param boundary: The multipart boundary as found in the Content-Type header.
@@ -901,7 +901,7 @@ def __init__(
901901
:param header_limit: Maximum number of headers per part.
902902
:param headersize_limit: Maximum length of a single header line (name and value).
903903
:param part_limit: Maximum number of parts.
904-
:param partsize_limit: Maximum content size of a single parts.
904+
:param partsize_limit: Maximum content size of a single part.
905905
:param spool_limit: Parts up to this size are buffered in memory and count
906906
towards `memory_limit`. Larger parts are spooled to temporary files on
907907
disk and count towards `disk_limit`.
@@ -970,7 +970,7 @@ def _iterparse(self):
970970
max_segment_count=self.part_limit,
971971
max_segment_size=self.partsize_limit,
972972
header_charset=self.charset,
973-
strict=self.strict
973+
strict=self.strict,
974974
)
975975

976976
with parser:

0 commit comments

Comments
 (0)