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.

Author Arfrever
Recipients Arfrever, hynek, tarek
Date 2013-06-22.15:29:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371914951.06.0.665120918364.issue18283@psf.upfronthosting.co.za>
In-reply-to
Content
shutil.which() should support bytes. Some other functions in shutil module support bytes.

>>> shutil.which("echo")
'/bin/echo'                                                                                                                                                  
>>> shutil.which(b"echo")                                                                                                                                    
Traceback (most recent call last):                                                                                                                           
  File "<stdin>", line 1, in <module>                                                                                                                        
  File "/usr/lib64/python3.3/shutil.py", line 1126, in which
    name = os.path.join(dir, thefile)
  File "/usr/lib64/python3.3/posixpath.py", line 92, in join
    "components.") from None
TypeError: Can't mix strings and bytes in path components.
>>> shutil.which("echo", path="/bin")
'/bin/echo'
>>> shutil.which("echo", path=b"/bin")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.3/shutil.py", line 1098, in which
    path = path.split(os.pathsep)
TypeError: Type str doesn't support the buffer API
>>> shutil.which(b"echo", path=b"/bin")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.3/shutil.py", line 1098, in which
    path = path.split(os.pathsep)
TypeError: Type str doesn't support the buffer API
History
Date User Action Args
2013-06-22 15:29:11Arfreversetrecipients: + Arfrever, tarek, hynek
2013-06-22 15:29:11Arfreversetmessageid: <1371914951.06.0.665120918364.issue18283@psf.upfronthosting.co.za>
2013-06-22 15:29:11Arfreverlinkissue18283 messages
2013-06-22 15:29:10Arfrevercreate