Message132799
shutil.copy2(file, dest) fails when dest has unicode characters:
[2011-04-02 17:19:54 adam@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 |
|
Date |
User |
Action |
Args |
2011-04-02 14:25:54 | Adam.Matan | set | recipients:
+ Adam.Matan |
2011-04-02 14:25:54 | Adam.Matan | set | messageid: <1301754354.21.0.769652184716.issue11741@psf.upfronthosting.co.za> |
2011-04-02 14:25:53 | Adam.Matan | link | issue11741 messages |
2011-04-02 14:25:53 | Adam.Matan | create | |
|