[Python-checkins] cpython: Issue #27034: Removed deprecated class asynchat.fifo.

serhiy.storchaka python-checkins at python.org
Mon May 16 02:32:25 EDT 2016


https://hg.python.org/cpython/rev/2af26a93f87f
changeset:   101358:2af26a93f87f
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon May 16 09:10:43 2016 +0300
summary:
  Issue #27034: Removed deprecated class asynchat.fifo.

files:
  Doc/library/asynchat.rst  |  16 ++++++------
  Lib/asynchat.py           |  29 -------------------------
  Lib/test/test_asynchat.py |  31 ---------------------------
  Misc/NEWS                 |   2 +
  4 files changed, 10 insertions(+), 68 deletions(-)


diff --git a/Doc/library/asynchat.rst b/Doc/library/asynchat.rst
--- a/Doc/library/asynchat.rst
+++ b/Doc/library/asynchat.rst
@@ -57,13 +57,13 @@
       The asynchronous output buffer size (default ``4096``).
 
    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
    transmitted on the channel.
    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
-   the :class:`async_chat` object removes the producer from the fifo and starts
-   using the next producer, if any. When the producer fifo is empty the
+   the :class:`async_chat` object removes the producer from the queue and starts
+   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:`set_terminator` method to describe how to recognize the end of, or
    an important breakpoint in, an incoming transmission from the remote
@@ -77,8 +77,8 @@
 
 .. method:: async_chat.close_when_done()
 
-   Pushes a ``None`` on to the producer fifo. When this producer is popped off
-   the fifo it causes the channel to be closed.
+   Pushes a ``None`` on to the producer queue. When this producer is popped off
+   the queue it causes the channel to be closed.
 
 
 .. method:: async_chat.collect_incoming_data(data)
@@ -91,7 +91,7 @@
 .. method:: async_chat.discard_buffers()
 
    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()
@@ -109,7 +109,7 @@
 
 .. 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
    network, although it is possible to use your own producers in more complex
    schemes to implement encryption and chunking, for example.
@@ -117,7 +117,7 @@
 
 .. 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
    channel will consume this producer's data by calling its :meth:`more`
    method and send the data to the remote endpoint.
diff --git a/Lib/asynchat.py b/Lib/asynchat.py
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -285,35 +285,6 @@
             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
 # assumes an exact match has already been checked.  Return the number of
 # characters matched.
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -296,37 +296,6 @@
         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):
     def test_disallow_negative_terminator(self):
         # Issue #11259
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -277,6 +277,8 @@
 Library
 -------
 
+- Issue #27034: Removed deprecated class asynchat.fifo.
+
 - Issue #26870: Added readline.set_auto_history(), which can stop entries
   being automatically added to the history list.  Based on patch by Tyler
   Crompton.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list