bpo-30427: eliminate redundant type checks in os.path.normcase() (GH-1712)

https://bugs.python.org/issue30427
This commit is contained in:
Wolfgang Maier 2019-03-28 22:47:18 +01:00 committed by Miss Islington (bot)
parent 02b84cb1b4
commit 74510e2a57
3 changed files with 7 additions and 15 deletions

View file

@ -46,16 +46,10 @@ def normcase(s):
Makes all characters lowercase and all slashes into backslashes."""
s = os.fspath(s)
try:
if isinstance(s, bytes):
return s.replace(b'/', b'\\').lower()
else:
return s.replace('/', '\\').lower()
except (TypeError, AttributeError):
if not isinstance(s, (bytes, str)):
raise TypeError("normcase() argument must be str or bytes, "
"not %r" % s.__class__.__name__) from None
raise
if isinstance(s, bytes):
return s.replace(b'/', b'\\').lower()
else:
return s.replace('/', '\\').lower()
# Return whether a path is absolute.