diff options
author | Georg Brandl <georg@python.org> | 2009-09-18 13:57:11 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-09-18 13:57:11 (GMT) |
commit | b0199518750feb2a37fe6ebfb9679329d3eb305f (patch) | |
tree | f991825a80f21b364ef525b889b47433656af22a /Lib | |
parent | c40e60e5e50f8ac1d157cf524f90d024c6bf31a3 (diff) | |
download | cpython-b0199518750feb2a37fe6ebfb9679329d3eb305f.zip cpython-b0199518750feb2a37fe6ebfb9679329d3eb305f.tar.gz cpython-b0199518750feb2a37fe6ebfb9679329d3eb305f.tar.bz2 |
Use str.format() to fix beginner's mistake with %-style string formatting.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/inspect.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 8eeb05d..ac3434d 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -402,12 +402,12 @@ def getfile(object): if ismodule(object): if hasattr(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): object = sys.modules.get(object.__module__) if hasattr(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): object = object.im_func if isfunction(object): @@ -418,8 +418,8 @@ def getfile(object): object = object.f_code if iscode(object): return object.co_filename - raise TypeError('%r is not a module, class, method, ' - 'function, traceback, frame, or code object' % object) + raise TypeError('{!r} is not a module, class, method, ' + 'function, traceback, frame, or code object'.format(object)) ModuleInfo = namedtuple('ModuleInfo', 'name suffix mode module_type') @@ -741,7 +741,7 @@ def getargs(co): 'varargs' and 'varkw' are the names of the * and ** arguments or None.""" 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 names = co.co_varnames @@ -805,7 +805,7 @@ def getargspec(func): if ismethod(func): func = func.im_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) return ArgSpec(args, varargs, varkw, func.func_defaults) @@ -902,7 +902,7 @@ def getframeinfo(frame, context=1): else: lineno = frame.f_lineno 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) if context > 0: |