Title: compileall doesn't support PEP 383 (undecodable paths/filenames)
Type: behavior Stage: patch review
Components: Library (Lib), Unicode Versions: Python 3.2, Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, haypo, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2011-02-10 12:38 by haypo, last changed 2011-05-10 22:38 by python-dev. This issue is now closed.

File name Uploaded Description Edit
compileall_surrogates.patch haypo, 2011-02-10 12:38
Messages (4)
msg128288 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-02-10 12:38
The compileall uses print("bla", filename, "bla") to write messages to the console. But the print fails if the filename cannot be encoded to the console encoding. It occurs if the filename is an undecodable filename encoded by the PEP 383 using surrogates. For example, UTF-8 cannot encode surrogates.

Attached patch uses repr() to escape surrogates: it adds also quotes to the filename. I don't know if it is a problem to add quotes. I prefer quotes, but it is more readable if the path or the filename contain spaces.
msg128421 - (view) Author: √Čric Araujo (eric.araujo) * (Python committer) Date: 2011-02-11 18:51
I agree that quotes help debugging, so +1 for repr (or !r, not sure which ones reads better).  Not sure this can make it into stable branches.
msg128994 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2011-02-21 20:58
Fixed by r88478.

> Not sure this can make it into stable branches.

I agree, I prefer to not touch stable releases.
msg135753 - (view) Author: Roundup Robot (python-dev) Date: 2011-05-10 22:38
New changeset 85cfbbc7da60 by Victor Stinner in branch '3.2':
Issue #11169: compileall module uses repr() to format filenames and paths to
Date User Action Args
2011-05-10 22:38:44python-devsetnosy: + python-dev
messages: + msg135753
2011-02-21 20:58:50hayposetstatus: open -> closed

messages: + msg128994
resolution: fixed
nosy: haypo, eric.araujo, r.david.murray
2011-02-11 18:51:10eric.araujosetnosy: + eric.araujo

messages: + msg128421
title: compileall doesn't support the PEP 383 (undecodable paths/filenames) -> compileall doesn't support PEP 383 (undecodable paths/filenames)
2011-02-10 21:51:11pitrousetnosy: + r.david.murray

type: behavior
components: + Library (Lib)
stage: patch review
2011-02-10 12:38:42haypocreate