8000 [2.7] Fix SyntaxWarning on importing test_inspect by vstinner · Pull Request #1512 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[2.7] Fix SyntaxWarning on importing test_inspect #1512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix SyntaxWarning on importing test_inspect
Fix the following warning when test_inspect.py is compiled to
test_inspect.pyc:

test_inspect.py:505: SyntaxWarning: tuple parameter unpacking has been removed in 3.x
  def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):

Replace also test.test_support import with test.support.
  • Loading branch information
vstinner committed May 9, 2017
commit b40d5b954756c0b73d4d30c71d96dfcbc5c3ed01
16 changes: 11 additions & 5 deletions Lib/test/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import inspect
import linecache
import datetime
import textwrap
from UserList import UserList
from UserDict import UserDict

from test.test_support import run_unittest, check_py3k_warnings, have_unicode
from test.support import run_unittest, check_py3k_warnings, have_unicode

with check_py3k_warnings(
("tuple parameter unpacking has been removed", SyntaxWarning),
Expand Down Expand Up @@ -502,10 +503,15 @@ def test_getargspec(self):
'g', 'h', (3, (4, (5,))),
'(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h)')

def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
def eggs():
return a + b + c + d + e + f + g + h
return eggs
with check_py3k_warnings(("tuple parameter unpacking has been removed",
SyntaxWarning),
quiet=True):
exec(textwrap.dedent('''
def spam_deref(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
def eggs():
return a + b + c + d + e + f + g + h
return eggs
'''))
self.assertArgSpecEquals(spam_deref,
['a', 'b', 'c', 'd', ['e', ['f']]],
'g', 'h', (3, (4, (5,))),
Expand Down
0