summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 9336943..b08e145 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -969,8 +969,13 @@ def getcallargs(func, *positional, **named):
assign(varkw, named)
elif named:
unexpected = next(iter(named))
- if isinstance(unexpected, unicode):
- unexpected = unexpected.encode(sys.getdefaultencoding(), 'replace')
+ try:
+ unicode
+ except NameError:
+ pass
+ else:
+ if isinstance(unexpected, unicode):
+ unexpected = unexpected.encode(sys.getdefaultencoding(), 'replace')
raise TypeError("%s() got an unexpected keyword argument '%s'" %
(f_name, unexpected))
unassigned = num_args - len([arg for arg in args if is_assigned(arg)])