Skip to content

Commit 23e043f

Browse files
committed
#17143: fix a missing import in the trace module. Initial patch by Berker Peksag.
1 parent 3a03d2e commit 23e043f

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

Lib/test/test_trace.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import os
2+
import io
23
import sys
34
from test.support import (run_unittest, TESTFN, rmtree, unlink,
45
captured_stdout)
6+
import tempfile
57
import unittest
68

79
import trace
@@ -361,6 +363,49 @@ def test_ignored(self):
361363
self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
362364

363365

366+
class TestDeprecatedMethods(unittest.TestCase):
367+
368+
def test_deprecated_usage(self):
369+
sio = io.StringIO()
370+
with self.assertWarns(DeprecationWarning):
371+
trace.usage(sio)
372+
self.assertIn('Usage:', sio.getvalue())
373+
374+
def test_deprecated_Ignore(self):
375+
with self.assertWarns(DeprecationWarning):
376+
trace.Ignore()
377+
378+
def test_deprecated_modname(self):
379+
with self.assertWarns(DeprecationWarning):
380+
self.assertEqual("spam", trace.modname("spam"))
381+
382+
def test_deprecated_fullmodname(self):
383+
with self.assertWarns(DeprecationWarning):
384+
self.assertEqual("spam", trace.fullmodname("spam"))
385+
386+
def test_deprecated_find_lines_from_code(self):
387+
with self.assertWarns(DeprecationWarning):
388+
def foo():
389+
pass
390+
trace.find_lines_from_code(foo.__code__, ["eggs"])
391+
392+
def test_deprecated_find_lines(self):
393+
with self.assertWarns(DeprecationWarning):
394+
def foo():
395+
pass
396+
trace.find_lines(foo.__code__, ["eggs"])
397+
398+
def test_deprecated_find_strings(self):
399+
with self.assertWarns(DeprecationWarning):
400+
with tempfile.NamedTemporaryFile() as fd:
401+
trace.find_strings(fd.name)
402+
403+
def test_deprecated_find_executable_linenos(self):
404+
with self.assertWarns(DeprecationWarning):
405+
with tempfile.NamedTemporaryFile() as fd:
406+
trace.find_executable_linenos(fd.name)
407+
408+
364409
def test_main():
365410
run_unittest(__name__)
366411

Lib/trace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import gc
5959
import dis
6060
import pickle
61+
from warnings import warn as _warn
6162
try:
6263
from time import monotonic as _time
6364
except ImportError:

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ Core and Builtins
178178
Library
179179
-------
180180

181+
- Issue #17143: Fix a missing import in the trace module. Initial patch by
182+
Berker Peksag.
183+
181184
- Issue #16743: Fix mmap overflow check on 32 bit Windows.
182185

183186
- Issue #16800: tempfile.gettempdir() no longer left temporary files when

0 commit comments

Comments
 (0)