Issue #11259: asynchat.async_chat().set_terminator() now raises a ValueError if
the number of received bytes is negative.
This commit is contained in:
parent
fd5d1b51d6
commit
630a4f63c5
|
@ -99,6 +99,8 @@ class async_chat(asyncore.dispatcher):
|
||||||
"""
|
"""
|
||||||
if isinstance(term, str) and self.use_encoding:
|
if isinstance(term, str) and self.use_encoding:
|
||||||
term = bytes(term, self.encoding)
|
term = bytes(term, self.encoding)
|
||||||
|
elif isinstance(term, int) and term < 0:
|
||||||
|
raise ValueError('the number of received bytes must be positive')
|
||||||
self.terminator = term
|
self.terminator = term
|
||||||
|
|
||||||
def get_terminator(self):
|
def get_terminator(self):
|
||||||
|
|
|
@ -304,5 +304,13 @@ class TestFifo(unittest.TestCase):
|
||||||
self.assertEqual(f.pop(), (0, None))
|
self.assertEqual(f.pop(), (0, None))
|
||||||
|
|
||||||
|
|
||||||
|
class TestNotConnected(unittest.TestCase):
|
||||||
|
def test_disallow_negative_terminator(self):
|
||||||
|
# Issue #11259
|
||||||
|
client = asynchat.async_chat()
|
||||||
|
self.assertRaises(ValueError, client.set_terminator, -1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -27,6 +27,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #11259: asynchat.async_chat().set_terminator() now raises a ValueError
|
||||||
|
if the number of received bytes is negative.
|
||||||
|
|
||||||
- Issue #12523: asynchat.async_chat.push() now raises a TypeError if it doesn't
|
- Issue #12523: asynchat.async_chat.push() now raises a TypeError if it doesn't
|
||||||
get a bytes string
|
get a bytes string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue