Commit 98019e1c authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #27034: Removed deprecated class asynchat.fifo.

parent 31e59aa7
...@@ -57,13 +57,13 @@ connection requests. ...@@ -57,13 +57,13 @@ connection requests.
The asynchronous output buffer size (default ``4096``). The asynchronous output buffer size (default ``4096``).
Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to Unlike :class:`asyncore.dispatcher`, :class:`async_chat` allows you to
define a first-in-first-out queue (fifo) of *producers*. A producer need define a :abbr:`FIFO (first-in, first-out)` queue of *producers*. A producer need
have only one method, :meth:`more`, which should return data to be have only one method, :meth:`more`, which should return data to be
transmitted on the channel. transmitted on the channel.
The producer indicates exhaustion (*i.e.* that it contains no more data) by The producer indicates exhaustion (*i.e.* that it contains no more data) by
having its :meth:`more` method return the empty bytes object. At this point having its :meth:`more` method return the empty bytes object. At this point
the :class:`async_chat` object removes the producer from the fifo and starts the :class:`async_chat` object removes the producer from the queue and starts
using the next producer, if any. When the producer fifo is empty the using the next producer, if any. When the producer queue is empty the
:meth:`handle_write` method does nothing. You use the channel object's :meth:`handle_write` method does nothing. You use the channel object's
:meth:`set_terminator` method to describe how to recognize the end of, or :meth:`set_terminator` method to describe how to recognize the end of, or
an important breakpoint in, an incoming transmission from the remote an important breakpoint in, an incoming transmission from the remote
...@@ -77,8 +77,8 @@ connection requests. ...@@ -77,8 +77,8 @@ connection requests.
.. method:: async_chat.close_when_done() .. method:: async_chat.close_when_done()
Pushes a ``None`` on to the producer fifo. When this producer is popped off Pushes a ``None`` on to the producer queue. When this producer is popped off
the fifo it causes the channel to be closed. the queue it causes the channel to be closed.
.. method:: async_chat.collect_incoming_data(data) .. method:: async_chat.collect_incoming_data(data)
...@@ -91,7 +91,7 @@ connection requests. ...@@ -91,7 +91,7 @@ connection requests.
.. method:: async_chat.discard_buffers() .. method:: async_chat.discard_buffers()
In emergencies this method will discard any data held in the input and/or In emergencies this method will discard any data held in the input and/or
output buffers and the producer fifo. output buffers and the producer queue.
.. method:: async_chat.found_terminator() .. method:: async_chat.found_terminator()
...@@ -109,7 +109,7 @@ connection requests. ...@@ -109,7 +109,7 @@ connection requests.
.. method:: async_chat.push(data) .. method:: async_chat.push(data)
Pushes data on to the channel's fifo to ensure its transmission. Pushes data on to the channel's queue to ensure its transmission.
This is all you need to do to have the channel write the data out to the This is all you need to do to have the channel write the data out to the
network, although it is possible to use your own producers in more complex network, although it is possible to use your own producers in more complex
schemes to implement encryption and chunking, for example. schemes to implement encryption and chunking, for example.
...@@ -117,7 +117,7 @@ connection requests. ...@@ -117,7 +117,7 @@ connection requests.
.. method:: async_chat.push_with_producer(producer) .. method:: async_chat.push_with_producer(producer)
Takes a producer object and adds it to the producer fifo associated with Takes a producer object and adds it to the producer queue associated with
the channel. When all currently-pushed producers have been exhausted the the channel. When all currently-pushed producers have been exhausted the
channel will consume this producer's data by calling its :meth:`more` channel will consume this producer's data by calling its :meth:`more`
method and send the data to the remote endpoint. method and send the data to the remote endpoint.
......
...@@ -285,35 +285,6 @@ class simple_producer: ...@@ -285,35 +285,6 @@ class simple_producer:
return result return result
class fifo:
def __init__(self, list=None):
import warnings
warnings.warn('fifo class will be removed in Python 3.6',
DeprecationWarning, stacklevel=2)
if not list:
self.list = deque()
else:
self.list = deque(list)
def __len__(self):
return len(self.list)
def is_empty(self):
return not self.list
def first(self):
return self.list[0]
def push(self, data):
self.list.append(data)
def pop(self):
if self.list:
return (1, self.list.popleft())
else:
return (0, None)
# Given 'haystack', see if any prefix of 'needle' is at its end. This # Given 'haystack', see if any prefix of 'needle' is at its end. This
# assumes an exact match has already been checked. Return the number of # assumes an exact match has already been checked. Return the number of
# characters matched. # characters matched.
......
...@@ -296,37 +296,6 @@ class TestHelperFunctions(unittest.TestCase): ...@@ -296,37 +296,6 @@ class TestHelperFunctions(unittest.TestCase):
self.assertEqual(asynchat.find_prefix_at_end("qwertydkjf", "\r\n"), 0) self.assertEqual(asynchat.find_prefix_at_end("qwertydkjf", "\r\n"), 0)
class TestFifo(unittest.TestCase):
def test_basic(self):
with self.assertWarns(DeprecationWarning) as cm:
f = asynchat.fifo()
self.assertEqual(str(cm.warning),
"fifo class will be removed in Python 3.6")
f.push(7)
f.push(b'a')
self.assertEqual(len(f), 2)
self.assertEqual(f.first(), 7)
self.assertEqual(f.pop(), (1, 7))
self.assertEqual(len(f), 1)
self.assertEqual(f.first(), b'a')
self.assertEqual(f.is_empty(), False)
self.assertEqual(f.pop(), (1, b'a'))
self.assertEqual(len(f), 0)
self.assertEqual(f.is_empty(), True)
self.assertEqual(f.pop(), (0, None))
def test_given_list(self):
with self.assertWarns(DeprecationWarning) as cm:
f = asynchat.fifo([b'x', 17, 3])
self.assertEqual(str(cm.warning),
"fifo class will be removed in Python 3.6")
self.assertEqual(len(f), 3)
self.assertEqual(f.pop(), (1, b'x'))
self.assertEqual(f.pop(), (1, 17))
self.assertEqual(f.pop(), (1, 3))
self.assertEqual(f.pop(), (0, None))
class TestNotConnected(unittest.TestCase): class TestNotConnected(unittest.TestCase):
def test_disallow_negative_terminator(self): def test_disallow_negative_terminator(self):
# Issue #11259 # Issue #11259
......
...@@ -277,6 +277,8 @@ Core and Builtins ...@@ -277,6 +277,8 @@ Core and Builtins
Library Library
------- -------
- Issue #27034: Removed deprecated class asynchat.fifo.
- Issue #26870: Added readline.set_auto_history(), which can stop entries - Issue #26870: Added readline.set_auto_history(), which can stop entries
being automatically added to the history list. Based on patch by Tyler being automatically added to the history list. Based on patch by Tyler
Crompton. Crompton.
......
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