[Python-3000] basestring removal, __file__ and co_filename

Christian Heimes lists at cheimes.de
Thu Oct 11 20:01:15 CEST 2007


Guido van Rossum wrote:
> Um, where does the filename object in that expression come from? It
> appears to be a PyString object. Who created it? That could should be
> changed to create a PyUnicode instead (using the filesystem encoding).

Python/compile.c:makecode()
filename = PyString_FromString(c->c_filename);

Modules/pyexpat.c:getcode()
filename = PyString_FromString(__FILE__);

Objects/codeobject.c:code_new()
PyArg_ParseTuple(args, "iiiiiSO!O!O!SSiS|O!O!:code"

As I tried to explain earlier that may be a problem. PyUnicode_Decode()
doesn't work so early. The codecs package isn't initialized yet.

Christian


More information about the Python-3000 mailing list