This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: posixpath.join() and bytearray
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Arfrever, chris.jerdonek, eric.araujo, hynek, ncoghlan, pitrou, python-dev, r.david.murray, serhiy.storchaka, terry.reedy
Priority: normal Keywords: patch

Created on 2014-07-22 09:33 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
posixpath_join_bytearray-3.4.diff serhiy.storchaka, 2014-07-22 09:33 review
posixpath_join_bytearray-3.5.diff serhiy.storchaka, 2014-07-22 09:33 review
Messages (4)
msg223654 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-07-22 09:33
posixpath.join() raises misleading exception in case when all arguments are bytearrays:

>>> import posixpath
>>> posixpath.join(bytearray(b'foo'), bytearray(b'bar'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/posixpath.py", line 91, in join
    "components.") from None
TypeError: Can't mix strings and bytes in path components.

This bug was introduced in issue15377 and misleading test which provoked it was added in issue15180.

I proposed two patches. Patch for 3.4 only eliminates wrong specialcasing of bytearray (none of os.path methods work with bytearray). Patch for 3.5 also adds better error messages for wrong argument types of posixpath.join (of course we can apply it to 3.4 too).
msg225261 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-13 07:22
Copied nosy list from issue15180 and issue15377.
msg225441 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-08-17 13:29
Could anyone please make the review?
msg225807 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-24 09:24
New changeset d9607a71456e by Serhiy Storchaka in branch '3.4':
Issue #22034: Got rid of misleading error message for bytearray arguments in
http://hg.python.org/cpython/rev/d9607a71456e

New changeset db600c927b2b by Serhiy Storchaka in branch 'default':
Issue #22034: Improve handling of wrong argument types in posixpath.join().
http://hg.python.org/cpython/rev/db600c927b2b
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66233
2014-08-24 09:25:57serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2014-08-24 09:24:43python-devsetnosy: + python-dev
messages: + msg225807
2014-08-17 13:29:49serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg225441
2014-08-13 07:26:37georg.brandlsetnosy: - georg.brandl
2014-08-13 07:22:44serhiy.storchakasetnosy: + georg.brandl, terry.reedy, pitrou, eric.araujo, Arfrever, r.david.murray, chris.jerdonek
messages: + msg225261
2014-07-22 09:33:58serhiy.storchakasetfiles: + posixpath_join_bytearray-3.5.diff
2014-07-22 09:33:29serhiy.storchakacreate