From c1b130acd0edb627e6e410dec5869216536a2594 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 10 Sep 2012 22:10:54 +0900 Subject: [PATCH] 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. --- doc/python.rst | 5 +++-- python/spdylay.pyx | 4 ++-- python/spdylay_tests.py | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/python.rst b/doc/python.rst index 296a14f9..594df515 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -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() diff --git a/python/spdylay.pyx b/python/spdylay.pyx index a2807a0a..3b694d84 100644 --- a/python/spdylay.pyx +++ b/python/spdylay.pyx @@ -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() diff --git a/python/spdylay_tests.py b/python/spdylay_tests.py index 0ae3720e..196e943e 100644 --- a/python/spdylay_tests.py +++ b/python/spdylay_tests.py @@ -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())