From 74510e2a57f6d4b51ac1ab4f778cd7a4c54b541e Mon Sep 17 00:00:00 2001 From: Wolfgang Maier Date: Thu, 28 Mar 2019 22:47:18 +0100 Subject: bpo-30427: eliminate redundant type checks in os.path.normcase() (GH-1712) https://bugs.python.org/issue30427 --- Lib/ntpath.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'Lib/ntpath.py') diff --git a/Lib/ntpath.py b/Lib/ntpath.py index b5e1d121fc..f3cfabf023 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -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. -- cgit v1.2.1