We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84b34ef commit 6e38d18Copy full SHA for 6e38d18
bpython/_py3compat.py
@@ -51,11 +51,15 @@ def prepare_for_exec(arg, encoding=None):
51
return arg.encode(encoding)
52
53
54
-def try_decode(s, encoding):
55
- """Try to decode s which is str names. Return None if not decodable"""
56
- if not py3 and not isinstance(s, unicode):
57
- try:
58
- return s.decode(encoding)
59
- except UnicodeDecodeError:
60
- return None
61
- return s
+if py3:
+ def try_decode(s, encoding):
+ return s
+else:
+ """Try to decode s which is str names. Return None if not decodable"""
+ if not isinstance(s, unicode):
+ try:
62
+ return s.decode(encoding)
63
+ except UnicodeDecodeError:
64
+ return None
65
0 commit comments