File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ def set_terminator(self, term):
9999 """
100100 if isinstance (term , str ) and self .use_encoding :
101101 term = bytes (term , self .encoding )
102+ elif isinstance (term , int ) and term < 0 :
103+ raise ValueError ('the number of received bytes must be positive' )
102104 self .terminator = term
103105
104106 def get_terminator (self ):
Original file line number Diff line number Diff line change @@ -311,5 +311,13 @@ def test_given_list(self):
311311 self .assertEqual (f .pop (), (0 , None ))
312312
313313
314+ class TestNotConnected (unittest .TestCase ):
315+ def test_disallow_negative_terminator (self ):
316+ # Issue #11259
317+ client = asynchat .async_chat ()
318+ self .assertRaises (ValueError , client .set_terminator , - 1 )
319+
320+
321+
314322if __name__ == "__main__" :
315323 unittest .main ()
Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ Core and Builtins
108108Library
109109-------
110110
111+ - Issue #11259: asynchat.async_chat().set_terminator() now raises a ValueError
112+ if the number of received bytes is negative.
113+
111114- Issue #12523: asynchat.async_chat.push() now raises a TypeError if it doesn't
112115 get a bytes string
113116
You can’t perform that action at this time.
0 commit comments