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
b0199518
Commit
b0199518
authored
Sep 18, 2009
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use str.format() to fix beginner's mistake with %-style string formatting.
parent
c40e60e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
Lib/inspect.py
Lib/inspect.py
+7
-7
No files found.
Lib/inspect.py
View file @
b0199518
...
@@ -402,12 +402,12 @@ def getfile(object):
...
@@ -402,12 +402,12 @@ def getfile(object):
if
ismodule
(
object
):
if
ismodule
(
object
):
if
hasattr
(
object
,
'__file__'
):
if
hasattr
(
object
,
'__file__'
):
return
object
.
__file__
return
object
.
__file__
raise
TypeError
(
'
%r is a built-in module'
%
object
)
raise
TypeError
(
'
{!r} is a built-in module'
.
format
(
object
)
)
if
isclass
(
object
):
if
isclass
(
object
):
object
=
sys
.
modules
.
get
(
object
.
__module__
)
object
=
sys
.
modules
.
get
(
object
.
__module__
)
if
hasattr
(
object
,
'__file__'
):
if
hasattr
(
object
,
'__file__'
):
return
object
.
__file__
return
object
.
__file__
raise
TypeError
(
'
%r is a built-in class'
%
object
)
raise
TypeError
(
'
{!r} is a built-in class'
.
format
(
object
)
)
if
ismethod
(
object
):
if
ismethod
(
object
):
object
=
object
.
im_func
object
=
object
.
im_func
if
isfunction
(
object
):
if
isfunction
(
object
):
...
@@ -418,8 +418,8 @@ def getfile(object):
...
@@ -418,8 +418,8 @@ def getfile(object):
object
=
object
.
f_code
object
=
object
.
f_code
if
iscode
(
object
):
if
iscode
(
object
):
return
object
.
co_filename
return
object
.
co_filename
raise
TypeError
(
'
%r
is not a module, class, method, '
raise
TypeError
(
'
{!r}
is not a module, class, method, '
'function, traceback, frame, or code object'
%
object
)
'function, traceback, frame, or code object'
.
format
(
object
)
)
ModuleInfo
=
namedtuple
(
'ModuleInfo'
,
'name suffix mode module_type'
)
ModuleInfo
=
namedtuple
(
'ModuleInfo'
,
'name suffix mode module_type'
)
...
@@ -741,7 +741,7 @@ def getargs(co):
...
@@ -741,7 +741,7 @@ def getargs(co):
'varargs' and 'varkw' are the names of the * and ** arguments or None."""
'varargs' and 'varkw' are the names of the * and ** arguments or None."""
if
not
iscode
(
co
):
if
not
iscode
(
co
):
raise
TypeError
(
'
%r is not a code object'
%
co
)
raise
TypeError
(
'
{!r} is not a code object'
.
format
(
co
)
)
nargs
=
co
.
co_argcount
nargs
=
co
.
co_argcount
names
=
co
.
co_varnames
names
=
co
.
co_varnames
...
@@ -805,7 +805,7 @@ def getargspec(func):
...
@@ -805,7 +805,7 @@ def getargspec(func):
if
ismethod
(
func
):
if
ismethod
(
func
):
func
=
func
.
im_func
func
=
func
.
im_func
if
not
isfunction
(
func
):
if
not
isfunction
(
func
):
raise
TypeError
(
'
%r is not a Python function'
%
func
)
raise
TypeError
(
'
{!r} is not a Python function'
.
format
(
func
)
)
args
,
varargs
,
varkw
=
getargs
(
func
.
func_code
)
args
,
varargs
,
varkw
=
getargs
(
func
.
func_code
)
return
ArgSpec
(
args
,
varargs
,
varkw
,
func
.
func_defaults
)
return
ArgSpec
(
args
,
varargs
,
varkw
,
func
.
func_defaults
)
...
@@ -902,7 +902,7 @@ def getframeinfo(frame, context=1):
...
@@ -902,7 +902,7 @@ def getframeinfo(frame, context=1):
else
:
else
:
lineno
=
frame
.
f_lineno
lineno
=
frame
.
f_lineno
if
not
isframe
(
frame
):
if
not
isframe
(
frame
):
raise
TypeError
(
'
%r is not a frame or traceback object'
%
frame
)
raise
TypeError
(
'
{!r} is not a frame or traceback object'
.
format
(
frame
)
)
filename
=
getsourcefile
(
frame
)
or
getfile
(
frame
)
filename
=
getsourcefile
(
frame
)
or
getfile
(
frame
)
if
context
>
0
:
if
context
>
0
:
...
...
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