Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
46c5cd0f
Commit
46c5cd0f
authored
Jun 11, 2018
by
Matthias Bussonnier
Committed by
Ned Deily
Jun 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33582: Emit deprecation warning for `formatargspec` (GH-6994)
parent
fd88f319
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
Lib/inspect.py
Lib/inspect.py
+14
-2
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+6
-4
Misc/NEWS.d/next/Library/2018-05-19-15-58-14.bpo-33582.qBZPmF.rst
...S.d/next/Library/2018-05-19-15-58-14.bpo-33582.qBZPmF.rst
+1
-0
No files found.
Lib/inspect.py
View file @
46c5cd0f
...
@@ -18,7 +18,7 @@ Here are some of the useful functions provided by this module:
...
@@ -18,7 +18,7 @@ Here are some of the useful functions provided by this module:
getargvalues(), getcallargs() - get info about function arguments
getargvalues(), getcallargs() - get info about function arguments
getfullargspec() - same, with support for Python 3 features
getfullargspec() - same, with support for Python 3 features
formatarg
spec(), formatarg
values() - format an argument spec
formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
getouterframes(), getinnerframes() - get info about frames
currentframe() - get the current stack frame
currentframe() - get the current stack frame
stack(), trace() - get info about frames on the stack or in a traceback
stack(), trace() - get info about frames on the stack or in a traceback
...
@@ -1211,7 +1211,19 @@ def formatargspec(args, varargs=None, varkw=None, defaults=None,
...
@@ -1211,7 +1211,19 @@ def formatargspec(args, varargs=None, varkw=None, defaults=None,
kwonlyargs, kwonlydefaults, annotations). The other five arguments
kwonlyargs, kwonlydefaults, annotations). The other five arguments
are the corresponding optional formatting functions that are called to
are the corresponding optional formatting functions that are called to
turn names and values into strings. The last argument is an optional
turn names and values into strings. The last argument is an optional
function to format the sequence of arguments."""
function to format the sequence of arguments.
Deprecated since Python 3.5: use the `signature` function and `Signature`
objects.
"""
from
warnings
import
warn
warn
(
"`formatargspec` is deprecated since Python 3.5. Use `signature` and "
" the `Signature` object directly"
,
DeprecationWarning
,
stacklevel
=
2
)
def
formatargandannotation
(
arg
):
def
formatargandannotation
(
arg
):
result
=
formatarg
(
arg
)
result
=
formatarg
(
arg
)
if
arg
in
annotations
:
if
arg
in
annotations
:
...
...
Lib/test/test_inspect.py
View file @
46c5cd0f
...
@@ -712,8 +712,9 @@ class TestClassesAndFunctions(unittest.TestCase):
...
@@ -712,8 +712,9 @@ class TestClassesAndFunctions(unittest.TestCase):
self
.
assertEqual
(
varkw
,
varkw_e
)
self
.
assertEqual
(
varkw
,
varkw_e
)
self
.
assertEqual
(
defaults
,
defaults_e
)
self
.
assertEqual
(
defaults
,
defaults_e
)
if
formatted
is
not
None
:
if
formatted
is
not
None
:
self
.
assertEqual
(
inspect
.
formatargspec
(
args
,
varargs
,
varkw
,
defaults
),
with
self
.
assertWarns
(
DeprecationWarning
):
formatted
)
self
.
assertEqual
(
inspect
.
formatargspec
(
args
,
varargs
,
varkw
,
defaults
),
formatted
)
def
assertFullArgSpecEquals
(
self
,
routine
,
args_e
,
varargs_e
=
None
,
def
assertFullArgSpecEquals
(
self
,
routine
,
args_e
,
varargs_e
=
None
,
varkw_e
=
None
,
defaults_e
=
None
,
varkw_e
=
None
,
defaults_e
=
None
,
...
@@ -729,8 +730,9 @@ class TestClassesAndFunctions(unittest.TestCase):
...
@@ -729,8 +730,9 @@ class TestClassesAndFunctions(unittest.TestCase):
self
.
assertEqual
(
kwonlydefaults
,
kwonlydefaults_e
)
self
.
assertEqual
(
kwonlydefaults
,
kwonlydefaults_e
)
self
.
assertEqual
(
ann
,
ann_e
)
self
.
assertEqual
(
ann
,
ann_e
)
if
formatted
is
not
None
:
if
formatted
is
not
None
:
self
.
assertEqual
(
inspect
.
formatargspec
(
args
,
varargs
,
varkw
,
defaults
,
with
self
.
assertWarns
(
DeprecationWarning
):
kwonlyargs
,
kwonlydefaults
,
ann
),
self
.
assertEqual
(
inspect
.
formatargspec
(
args
,
varargs
,
varkw
,
defaults
,
kwonlyargs
,
kwonlydefaults
,
ann
),
formatted
)
formatted
)
def
test_getargspec
(
self
):
def
test_getargspec
(
self
):
...
...
Misc/NEWS.d/next/Library/2018-05-19-15-58-14.bpo-33582.qBZPmF.rst
0 → 100644
View file @
46c5cd0f
Emit a deprecation warning for inspect.formatargspec
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment