mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
Issue #22034: Improve handling of wrong argument types in posixpath.join().
This commit is contained in:
commit
1fa36268cf
2 changed files with 20 additions and 21 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue