[New-bugs-announce] [issue22034] posixpath.join() and bytearray

Serhiy Storchaka report at bugs.python.org
Tue Jul 22 11:33:29 CEST 2014

New submission from Serhiy Storchaka:

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).

components: Library (Lib)
files: posixpath_join_bytearray-3.4.diff
keywords: patch
messages: 223654
nosy: hynek, ncoghlan, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: posixpath.join() and bytearray
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file36028/posixpath_join_bytearray-3.4.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list