[Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII

Victor Stinner victor.stinner at haypocalc.com
Mon May 9 16:11:15 CEST 2011

Le lundi 09 mai 2011 à 09:00 -0400, Jim Jewett a écrit :
> Are you asserting that all foreign modules (or at least all handled by
> this) are in C, as opposed to C++ or even Java or Fortran?  (And the C
> won't change?)

C and C++ identifiers are restricted to ASCII. I don't know for Fortran
or Java.

Is it possible to write a CPython extension module in Java or Fortran?

(My change doesn't concern Jython: it's an implementation detail of
dynamic modules in CPython.)

> Is this ASCII restriction (as opposed to even UTF8) really needed?

I prefer to explicitly limit module names of dynamic modules to ASCII.

If we decide to extend the support to something else than ASCII, we will
need a working module to test it, and maybe also a test.

> Or are you just saying that we need to create an ASCII name for passing to C?

You pass a Unicode module name to import (import hé or
__import__('hé')), and Python encodes the name to ASCII if it is a
dynamic module. It is still possible to use non-ASCII module names, but
only for modules written in Python.


More information about the Python-Dev mailing list