Skip to content

Commit c7fde72

Browse files
committed
[refs sigmavirus24#112] Wrapping StringIO with an adaptor to deal with change to the method signature expected by requests
1 parent 8ccec57 commit c7fde72

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

github3/decorators.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
from io import BytesIO as StringIO
1919

2020

21+
class RequestsStringIO(StringIO):
22+
def read(self, chunk_size, *args, **kwargs):
23+
return super(RequestsStringIO, self).read(chunk_size)
24+
25+
2126
def requires_auth(func):
2227
"""Decorator to note which object methods require authorization."""
2328
@wraps(func)
@@ -61,7 +66,7 @@ def generate_fake_error_response(msg, status_code=401, encoding='utf-8'):
6166
r = Response()
6267
r.status_code = status_code
6368
r.encoding = encoding
64-
r.raw = StringIO(msg)
69+
r.raw = RequestsStringIO(msg)
6570
r._content_consumed = True
6671
r._content = r.raw.read()
6772
return r

0 commit comments

Comments
 (0)