[Python-Dev] Modules of plat-* directories

Victor Stinner victor.stinner at haypocalc.com
Mon Oct 17 01:16:36 CEST 2011


I don't understand why we kept modules of the plat-* directories (e.g. 
Lib/plat-linux/CDROM.py). It looks like these modules are not used, except 
maybe some DL constants used by PyKDE4. Can't we move used constants to 
classic Python modules (e.g. the os module) and drop unused modules?

These modules are not regenerated when Python is compiled, so I don't 
understand how values can be correct. For example, IN.INT_MAX is 2147483647, 
whereas it should be 9223372036854775807 on my 64-bit Linux. These values 
don't look reliable.

I'm looking at these modules because Arfrever asked me to review a patch for 
h2py.py, a script to regenerate these modules:

He also suggested somewhere to regenerate these modules when Python is built.


Python has builtin modules generated from C header files:

- CDIO: sunos5
- CDROM: linux
- DLFCN: linux, sunos5
- _emx_link: os2emx
- grp: os2emx
- IN: aix4, darwin, freebsd[45678], linux, netbsd1, os2emx, sunos5, unixware7
- pwd: os2emx
- SOCKET: os2emx
- STROPTS: sunos5, unixware7
- TYPES: linux, sunos5

CDROM/CDIO can be used to control the low-level CDROM API. CDROM is used by 
the cdsuite project:

DLFCN is used by PyKDE4: sys.setdlopenflags(DLFCN.RTLD_NOW|DLFCN.RTLD_GLOBAL). 
I didn't know this sys function :-)

(OS/2 platform is deprecated, see PEP 11.)

The IN module is used by policykit to get INT_MAX (used to compute 
"MAX_DBUS_TIMEOUT = INT_MAX / 1000.0"). It was also used in SGI video demos of 
Python 1.4.

STROPTS is not used.

TYPES is used by other plat-* modules (IN, DLFCN, STROPTS).

These modules contain non-working functions:

def __STRING(x): return #x                                                      
def __constant_le32_to_cpu(x): return ((__u32)(__le32)(x))

__STRING(x) returns None, "#x" is a comment in Python (in C, the preprocessor 
converts x to a string). Call __constant_le32_to_cpu() fails because __le32 is 
not defined. Even if __le32 was defined, the code doesn't look to be valid.


More information about the Python-Dev mailing list