]> granicus.if.org Git - python/commitdiff
#6916: raise a deprecation warning if using asynchat.fifo
authorGiampaolo Rodola' <g.rodola@gmail.com>
Sat, 21 Jun 2014 11:58:30 +0000 (13:58 +0200)
committerGiampaolo Rodola' <g.rodola@gmail.com>
Sat, 21 Jun 2014 11:58:30 +0000 (13:58 +0200)
Lib/asynchat.py
Lib/test/test_asynchat.py

index f1a5731bae802026920abb1ab46ada8882f2e2d7..ac83eeae72bfb494277924b503274a0ad4ebd4ce 100644 (file)
@@ -275,6 +275,9 @@ class simple_producer:
 
 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:
index f93a52d8c98973add312f5eec7e07777ff19bb4c..dd606d662db10bd2cca116fb0e514d83bb6d1422 100644 (file)
@@ -8,6 +8,7 @@ thread = support.import_module('_thread')
 import asyncore, asynchat, socket, time
 import unittest
 import sys
+import warnings
 try:
     import threading
 except ImportError:
@@ -260,7 +261,9 @@ class TestHelperFunctions(unittest.TestCase):
 
 class TestFifo(unittest.TestCase):
     def test_basic(self):
-        f = asynchat.fifo()
+        with warnings.catch_warnings(record=True) as w:
+            f = asynchat.fifo()
+            assert issubclass(w[0].category, DeprecationWarning)
         f.push(7)
         f.push(b'a')
         self.assertEqual(len(f), 2)
@@ -275,7 +278,9 @@ class TestFifo(unittest.TestCase):
         self.assertEqual(f.pop(), (0, None))
 
     def test_given_list(self):
-        f = asynchat.fifo([b'x', 17, 3])
+        with warnings.catch_warnings(record=True) as w:
+            f = asynchat.fifo([b'x', 17, 3])
+            assert issubclass(w[0].category, DeprecationWarning)
         self.assertEqual(len(f), 3)
         self.assertEqual(f.pop(), (1, b'x'))
         self.assertEqual(f.pop(), (1, 17))