[Python-checkins] cpython: #6916: raise a deprecation warning if using asynchat.fifo
giampaolo.rodola
python-checkins at python.org
Sat Jun 21 13:59:35 CEST 2014
http://hg.python.org/cpython/rev/233168a2a656
changeset: 91305:233168a2a656
parent: 91175:42a645d74e9d
user: Giampaolo Rodola' <g.rodola at gmail.com>
date: Sat Jun 21 13:58:30 2014 +0200
summary:
#6916: raise a deprecation warning if using asynchat.fifo
files:
Lib/asynchat.py | 3 +++
Lib/test/test_asynchat.py | 9 +++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Lib/asynchat.py b/Lib/asynchat.py
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -275,6 +275,9 @@
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:
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
@@ -8,6 +8,7 @@
import asyncore, asynchat, socket, time
import unittest
import sys
+import warnings
try:
import threading
except ImportError:
@@ -260,7 +261,9 @@
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 @@
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))
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list