Python 1.5.2 on HPUX 10.20

Robert Roy rjroy at takingcontrol.com
Wed Aug 25 15:14:50 CEST 1999


On Wed, 25 Aug 1999 13:38:37 +0200, Volker Hetzer
<volker.hetzer at abg1.siemens.de> wrote:

>Hi!
>This is my first look into python. I tried to install it
>% ./configure --prefix=/opt/python
>% make all install
>
>and to test it
>% make test
>
>The fcntl test failed (twice):
>
>% /opt/python/bin/python Lib/test/test_fcntl.py
>Status from fnctl with O_NONBLOCK:  0
>struct.pack:  '\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000'
>Traceback (innermost last):
>  File "Lib/test/test_fcntl.py", line 30, in ?
>    rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata)
>IOError: [Errno 22] Invalid argument
>%
>
>Is this serious? What am I to do?
>
>Greetings!
>Volker
>
>-- 
>Hi! I'm a signature virus! Copy me into your signature file to help me spread!

Hi Volker,

I have run into this problem before. Where things worked fine on our
HP-UX but not on our client's. There is a relatively simple fix.

The file lib/python1.5/plat-hp-uxB/FCNTL.py is generated from header
files. In one of the header files there is a conditional that is
evaluated. The program that generates the Python does not understand
the conditional thus defines some values twice.


....
bunch of stuff

#if !defined(_FILE64)
#  define F_GETLK	5	/* Get file lock */
#  define F_SETLK	6	/* Set file lock */
#  define F_SETLKW	7	/* Set file lock and wait */
#else
#  define F_GETLK       8	/* FILE_OFFSET_BITS=64 name space */
#  define F_SETLK       9	/* Map GET/SETLK to their 64-bit */
#  define F_SETLKW      10	/* counter parts */
#endif /* !_FILE64 */

... more stuff

This generates the following python code

# Included from sys/fcntl.h

# Included from sys/types.h

# Included from sys/_inttypes.h
MAXSUSE = 65535
MAXFUPLIM = 60000
MAXFUPLIM = 2048
FD_SETSIZE = MAXFUPLIM
FD_SETSIZE = MAXFUPLIM

# Included from .unsupp/sys/_types.h
F_DUPFD = 0
F_GETFD = 1
F_SETFD = 2
F_GETFL = 3
F_SETFL = 4
F_GETLK = 5	<<<
F_SETLK = 6	<<<
F_SETLKW = 7	<<<
F_GETLK = 8	<<<<2nd def
F_SETLK = 9	<<<<2nd def
F_SETLKW = 10	<<<< 2nd def
F_GETLK64 = 8
F_SETLK64 = 9
F_SETLKW64 = 10
F_GETOWN = 11
F_SETOWN = 12
FD_CLOEXEC = 1
F_RDLCK = 01
F_WRLCK = 02
F_UNLCK = 03
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2

.... and more

This means that regardless of the system under which it is compiled,
FCNTL.py sets the values of these vars to the second value. Of course
the OS expects otherwise. Thus if you have a system that uses _FILE64
your fcntl test breaks.

The fix? 3 little # marks. comment out the second set of definitions
and things should work.

Good Luck!


Robert Roy
rjroy-nospam at takingcontrol.com




More information about the Python-list mailing list