summaryrefslogtreecommitdiff
path: root/Lib/posixpath.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-08-24 12:23:36 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2014-08-24 12:23:36 +0300
commit1fa36268cfdac3760de37859aa3ec1b5121248c5 (patch)
tree98f22fd456dcbba258133cd82404352d647985b2 /Lib/posixpath.py
parent66106626edb739f7d5dd3d0a7a2dd634a0e5a0b8 (diff)
parent549c1972f2b063e3d36ffff6c917372db512e7d4 (diff)
downloadcpython-git-1fa36268cfdac3760de37859aa3ec1b5121248c5.tar.gz
Issue #22034: Improve handling of wrong argument types in posixpath.join().
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r--Lib/posixpath.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index eb17dbab07..f08c9310d4 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -82,14 +82,13 @@ def join(a, *p):
path += b
else:
path += sep + b
- except TypeError:
- valid_types = all(isinstance(s, (str, bytes, bytearray))
- for s in (a, ) + p)
- if valid_types:
- # Must have a mixture of text and binary data
- raise TypeError("Can't mix strings and bytes in path "
- "components.") from None
- raise
+ except (TypeError, AttributeError):
+ for s in (a,) + p:
+ if not isinstance(s, (str, bytes)):
+ raise TypeError('join() argument must be str or bytes, not %r' %
+ s.__class__.__name__) from None
+ # Must have a mixture of text and binary data
+ raise TypeError("Can't mix strings and bytes in path components") from None
return path