[New-bugs-announce] [issue23327] zipimport to import from non-ascii pathname on Windows

Swapneel Ambre report at bugs.python.org
Mon Jan 26 23:43:56 CET 2015

New submission from Swapneel Ambre:

On Windows, using zipimport module APIs like get_filename on a file with non-ascii characters in the full path fails with 

UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character ( Full output attached in errorlog.txt ).

The issue is that Modules/zipimport.c has a function compile_source which tries to run PyUnicode_EncodeFSDefault on the pathname. On Windows, the default encoding is 'mbcs' which cannot handle unicode characters.

This has already been fixed in the import machinery on python 3 ( see issue http://bugs.python.org/issue13758, http://bugs.python.org/issue11619). The solution is to pass the pathname as Unicode directly to the compiler.

components: Unicode, Windows
files: errorlog.txt
messages: 234786
nosy: amswap, ezio.melotti, haypo, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: zipimport to import from non-ascii pathname on Windows
type: crash
versions: Python 3.4
Added file: http://bugs.python.org/file37872/errorlog.txt

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list