[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Ezio Melotti
Ezio Melotti added the comment: Mixing byte and unicode strings should always be avoided, because the implicit coercion to unicode works only if the byte strings contains only ASCII, and fails otherwise. Several modules -- including shutil, glob, and os.path -- have API that work with both by

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Adam Matan
Adam Matan added the comment: Do you think it should be fixed at the module level? -- ___ Python tracker ___ ___ Python-bugs-list mai

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Ezio Melotti
Ezio Melotti added the comment: The ASCII filename is already converted to unicode, but in your case the program was most likely failing with some non-ASCII filename. -- ___ Python tracker ___

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Adam Matan
Adam Matan added the comment: Don't you think it should be changed in Python 2.x, so that the ASCII filename will be automatically converted to to Unicode? -- ___ Python tracker __

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Ezio Melotti
Ezio Melotti added the comment: I should have added that both 'א' and u'א' work as long as the file names in the list returned by glob() are ASCII: if u'א' is used they are simply coerced to unicode. If there are non-ASCII file names in the glob() list, the copy fails because Python 2 tries t

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Adam Matan
Adam Matan added the comment: Don't you think that shutil should be able to handle mixed data types, for example byte string as file name and unicode destination directory? This is, in my opinion, a very common scenario. Would you consider converting all arguments to Unicode? -- ___

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Ezio Melotti
Ezio Melotti added the comment: The problem here is that you are mixing byte strings and unicode. glob.glob('*.ods') returns a list of strings, so in shutil.copy2(file, 'א') you are passing two byte strings and everything works fine. In shutil.copy2(file, u'א') instead, file is a byte string, a

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Ezio Melotti
Changes by Ezio Melotti : -- components: +Library (Lib) -Extension Modules nosy: +ezio.melotti stage: -> test needed type: -> behavior ___ Python tracker ___ __

[issue11741] shutil2.copy fails with destination filenames

2011-04-02 Thread Adam Matan
New submission from Adam Matan : 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 inform