Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd04876

Browse files
committed
#6916: raise a deprecation warning if using asynchat.fifo
1 parent 892051a commit bd04876

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/asynchat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ def more (self):
275275

276276
class fifo:
277277
def __init__ (self, list=None):
278+
import warnings
279+
warnings.warn('fifo class will be removed in Python 3.6',
280+
DeprecationWarning, stacklevel=2)
278281
if not list:
279282
self.list = deque()
280283
else:

Lib/test/test_asynchat.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import asyncore, asynchat, socket, time
99
import unittest
1010
import sys
11+
import warnings
1112
try:
1213
import threading
1314
except ImportError:
@@ -260,7 +261,9 @@ def test_find_prefix_at_end(self):
260261

261262
class TestFifo(unittest.TestCase):
262263
def test_basic(self):
263-
f = asynchat.fifo()
264+
with warnings.catch_warnings(record=True) as w:
265+
f = asynchat.fifo()
266+
assert issubclass(w[0].category, DeprecationWarning)
264267
f.push(7)
265268
f.push(b'a')
266269
self.assertEqual(len(f), 2)
@@ -275,7 +278,9 @@ def test_basic(self):
275278
self.assertEqual(f.pop(), (0, None))
276279

277280
def test_given_list(self):
278-
f = asynchat.fifo([b'x', 17, 3])
281+
with warnings.catch_warnings(record=True) as w:
282+
f = asynchat.fifo([b'x', 17, 3])
283+
assert issubclass(w[0].category, DeprecationWarning)
279284
self.assertEqual(len(f), 3)
280285
self.assertEqual(f.pop(), (1, b'x'))
281286
self.assertEqual(f.pop(), (1, 17))

0 commit comments

Comments
 (0)