1
0
mirror of https://github.com/moparisthebest/spdylay synced 2024-12-21 23:28:52 -05:00

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.
This commit is contained in:
Tatsuhiro Tsujikawa 2012-09-10 22:10:54 +09:00
parent ba63d00db5
commit c1b130acd0
3 changed files with 6 additions and 6 deletions

View File

@ -258,8 +258,9 @@ Session Objects
Puts back previously deferred DATA frame in the stream *stream_id*
to the outbound queue.
The :py:class:`InvalidArgumentError` will be raised if the stream
does not exist or no deferred data exist.
This method returns ``True`` if it succeeds, or ``False``. This
method will fail if the stream does not exist or no deferred data
exist.
.. py:method:: Session.want_read()

View File

@ -778,9 +778,9 @@ cdef class Session:
cpdef int rv
rv = cspdylay.spdylay_session_resume_data(self._c_session, stream_id)
if rv == 0:
return
return True
elif rv == cspdylay.SPDYLAY_ERR_INVALID_ARGUMENT:
raise InvalidArgumentError(_strerror(rv))
return False
elif rv == cspdylay.SPDYLAY_ERR_NOMEM:
raise MemoryError()

View File

@ -174,8 +174,7 @@ class SpdylayTests(unittest.TestCase):
self.assertEqual(spdylay.GOAWAY_PROTOCOL_ERROR, frame.status_code)
def test_resume_data(self):
with self.assertRaises(spdylay.InvalidArgumentError):
self.client_session.resume_data(1)
self.assertFalse(self.client_session.resume_data(1))
def test_get_pri_lowest(self):
self.assertEqual(7, self.client_session.get_pri_lowest())