Skip to content

Commit

Permalink
Make multipart.boundary a str property (#2589)
Browse files Browse the repository at this point in the history
* Make multipart.boundary a str property

* Add changenote
  • Loading branch information
asvetlov authored Dec 5, 2017
1 parent 50b69c8 commit 7c6f0bc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/2589.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`MultipartWriter.boundary` is `str` now.
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

0 comments on commit 7c6f0bc

Please sign in to comment.