10000 Response object compabtibility (#55) · nirum-lang/nirum-python@e6d036b · GitHub
[go: up one dir, main page]

Skip to content

Commit e6d036b

Browse files
authored
Response object compabtibility (#55)
* response has .code only in python2 * 0.3.6 * response has .code always
1 parent c68554b commit e6d036b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

nirum/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
~~~~~~~~~~~~~~~
33
44
"""
5-
__version_info__ = 0, 3, 5
5+
__version_info__ = 0, 3, 6
66
__version__ = '.'.join(str(v) for v in __version_info__)

nirum/rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def do_request(self, request_url, payload):
391391
request.add_header(header_name, header_content)
392392
response = self.opener.open(request, None)
393393
response_text = response.read()
394-
if 200 <= response.status < 300:
394+
if 200 <= response.code < 300:
395395
return response_text.decode('utf-8')
396396
else:
397397
raise UnexpectedNirumResponseError(response_text)

nirum/test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import socket
22

3+
from six import PY3
34
from six.moves import urllib
45
from six.moves.http_client import HTTPResponse
56
from werkzeug.test import Client
@@ -15,7 +16,9 @@ class MockHttpResponse(HTTPResponse):
1516

1617
def __init__(self, body, status_code):
1718
self.body = body
18-
self.status = status_code
19+
self.code = status_code
20+
if PY3:
21+
self.status = status_code
1922

2023
def read(self):
2124
return self.body.encode('utf-8')

0 commit comments

Comments
 (0)
0