Commit bd048769 authored by Giampaolo Rodola's avatar Giampaolo Rodola

#6916: raise a deprecation warning if using asynchat.fifo

parent 892051af
...@@ -275,6 +275,9 @@ class simple_producer: ...@@ -275,6 +275,9 @@ class simple_producer:
class fifo: class fifo:
def __init__ (self, list=None): def __init__ (self, list=None):
import warnings
warnings.warn('fifo class will be removed in Python 3.6',
DeprecationWarning, stacklevel=2)
if not list: if not list:
self.list = deque() self.list = deque()
else: else:
......
...@@ -8,6 +8,7 @@ thread = support.import_module('_thread') ...@@ -8,6 +8,7 @@ thread = support.import_module('_thread')
import asyncore, asynchat, socket, time import asyncore, asynchat, socket, time
import unittest import unittest
import sys import sys
import warnings
try: try:
import threading import threading
except ImportError: except ImportError:
...@@ -260,7 +261,9 @@ class TestHelperFunctions(unittest.TestCase): ...@@ -260,7 +261,9 @@ class TestHelperFunctions(unittest.TestCase):
class TestFifo(unittest.TestCase): class TestFifo(unittest.TestCase):
def test_basic(self): 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(7)
f.push(b'a') f.push(b'a')
self.assertEqual(len(f), 2) self.assertEqual(len(f), 2)
...@@ -275,7 +278,9 @@ class TestFifo(unittest.TestCase): ...@@ -275,7 +278,9 @@ class TestFifo(unittest.TestCase):
self.assertEqual(f.pop(), (0, None)) self.assertEqual(f.pop(), (0, None))
def test_given_list(self): 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(len(f), 3)
self.assertEqual(f.pop(), (1, b'x')) self.assertEqual(f.pop(), (1, b'x'))
self.assertEqual(f.pop(), (1, 17)) self.assertEqual(f.pop(), (1, 17))
......
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