Commit c1b130ac authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

python: Don't raise exception from Session.resume_data()

In practice, Session.resume_data() will be used without checking there
is deferred data or not. Actually, there is no API to check this.  So
it is better not to raise exception. Instead return False to notify
error. If the method succeeds, it returns True.
parent ba63d00d
...@@ -258,8 +258,9 @@ Session Objects ...@@ -258,8 +258,9 @@ Session Objects
Puts back previously deferred DATA frame in the stream *stream_id* Puts back previously deferred DATA frame in the stream *stream_id*
to the outbound queue. to the outbound queue.
The :py:class:`InvalidArgumentError` will be raised if the stream This method returns ``True`` if it succeeds, or ``False``. This
does not exist or no deferred data exist. method will fail if the stream does not exist or no deferred data
exist.
.. py:method:: Session.want_read() .. py:method:: Session.want_read()
......
...@@ -778,9 +778,9 @@ cdef class Session: ...@@ -778,9 +778,9 @@ cdef class Session:
cpdef int rv cpdef int rv
rv = cspdylay.spdylay_session_resume_data(self._c_session, stream_id) rv = cspdylay.spdylay_session_resume_data(self._c_session, stream_id)
if rv == 0: if rv == 0:
return return True
elif rv == cspdylay.SPDYLAY_ERR_INVALID_ARGUMENT: elif rv == cspdylay.SPDYLAY_ERR_INVALID_ARGUMENT:
raise InvalidArgumentError(_strerror(rv)) return False
elif rv == cspdylay.SPDYLAY_ERR_NOMEM: elif rv == cspdylay.SPDYLAY_ERR_NOMEM:
raise MemoryError() raise MemoryError()
......
...@@ -174,8 +174,7 @@ class SpdylayTests(unittest.TestCase): ...@@ -174,8 +174,7 @@ class SpdylayTests(unittest.TestCase):
self.assertEqual(spdylay.GOAWAY_PROTOCOL_ERROR, frame.status_code) self.assertEqual(spdylay.GOAWAY_PROTOCOL_ERROR, frame.status_code)
def test_resume_data(self): def test_resume_data(self):
with self.assertRaises(spdylay.InvalidArgumentError): self.assertFalse(self.client_session.resume_data(1))
self.client_session.resume_data(1)
def test_get_pri_lowest(self): def test_get_pri_lowest(self):
self.assertEqual(7, self.client_session.get_pri_lowest()) self.assertEqual(7, self.client_session.get_pri_lowest())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment