[New-bugs-announce] [issue11741] shutil2.copy fails with destination filenames

Adam Matan report at bugs.python.org
Sat Apr 2 16:25:54 CEST 2011


New submission from Adam Matan <adam at matan.name>:

shutil.copy2(file, dest) fails when dest has unicode characters:

[2011-04-02 17:19:54 adam at adam-laptop ~/personal :) ]$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>> import shutil
>>> files=glob.glob('*.ods')
>>> for file in files:
...     shutil.copy2(file, 'א') # This works, but:
...
>>> for file in files:
...     shutil.copy2(file, u'א')
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib/python2.6/shutil.py", line 98, in copy2
    dst = os.path.join(dst, os.path.basename(src))
  File "/usr/lib/python2.6/posixpath.py", line 70, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 1: ordinal not in range(128)


See discussion here: http://stackoverflow.com/questions/5523373/python-how-to-move-a-file-with-unicode-filename-to-a-unicode-folder/5523385#5523385

----------
components: Extension Modules
messages: 132799
nosy: Adam.Matan
priority: normal
severity: normal
status: open
title: shutil2.copy fails with destination filenames
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11741>
_______________________________________


More information about the New-bugs-announce mailing list