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 jaraco
Recipients Steffen Kampmann, jaraco, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-07-30.03:46:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1469850384.71.0.956677672537.issue24672@psf.upfronthosting.co.za>
In-reply-to
Content
I've confirmed the issue. It does indeed only occur if the string passed to rmtree is bytes. I discovered this during my investigation of https://github.com/cherrypy/cherrypy/issues/1467. The following script will replicate the failure on Windows systems on Python 2 and Python 3, but not on other operating systems:

---
# encoding: utf-8

from __future__ import unicode_literals

import os
import shutil

os.mkdir('temp')

with open('temp/Слава Україні.html', 'w'):
    pass

print(os.listdir(b'temp')[0])

shutil.rmtree(b'temp')
---

The error on Python 2.7 is this:

????? ???????.html
Traceback (most recent call last):
  File "C:\Users\jaraco\p\cherrypy\issue-1467.py", line 15, in <module>
    shutil.rmtree(b'temp')
  File "C:\Program Files\Python27\lib\shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "C:\Program Files\Python27\lib\shutil.py", line 250, in rmtree
    os.remove(fullname)
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'temp\\????? ???????.html'

This issue might be related to issue25911 or issue24230 or issue18713 or issue16656 or issue9820 and probably others.


It's not obvious to me browsing through those tickets why Windows should behave differently when a bytestring is passed to listdir. Perhaps I'll delve into those tickets in more depth.
History
Date User Action Args
2016-07-30 03:46:24jaracosetrecipients: + jaraco, paul.moore, vstinner, tim.golden, zach.ware, steve.dower, Steffen Kampmann
2016-07-30 03:46:24jaracosetmessageid: <1469850384.71.0.956677672537.issue24672@psf.upfronthosting.co.za>
2016-07-30 03:46:24jaracolinkissue24672 messages
2016-07-30 03:46:22jaracocreate