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

Make multipart.boundary a str property #2589

Merged
merged 3 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def _boundary_value(self):
# / DIGIT / ALPHA
# ; any VCHAR, except delimiters
# VCHAR = %x21-7E
value = self.boundary
value = self._boundary
if re.match(self._valid_tchar_regex, value):
return value.decode('ascii') # cannot fail

Expand All @@ -701,7 +701,7 @@ def _boundary_value(self):

@property
def boundary(self):
return self._boundary
return self._boundary.decode('ascii')

def append(self, obj, headers=None):
if headers is None:
Expand Down
6 changes: 5 additions & 1 deletion docs/multipart_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ Multipart reference

.. attribute:: boundary

The byte-string representation of the boundary.
The string (:class:`str`) representation of the boundary.

.. versionchanged:: 3.0

Property type was changed from :class:`bytes` to :class:`str`.

.. method:: append(obj, headers=None)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ async def test_reading_skips_prelude(self):

async def test_writer(writer):
assert writer.size == 0
assert writer.boundary == b':'
assert writer.boundary == ':'


async def test_writer_serialize_io_chunk(buf, stream, writer):
Expand Down