* Jakub Wilk <[EMAIL PROTECTED]>, 2008-03-06, 20:38:
Package: python-pyrex
Version: 0.9.6.4-1
Severity: normal

$ echo "print hash('foobar')" > hash.pyx
$ pyrexc hash.pyx > hash.c

[On a i386 machine:]

$ python hash.pyx
-1969371895
$ gcc -fPIC -shared -I/usr/include/python2.4/ -lpython2.4 hash.c -o hash.so
$ python -c 'import hash'
-1969371895

[On a amd64 machine:]

$ python hash.pyx
3433925302934160649
$ gcc -fPIC -shared-I /usr/include/python2.4/ -lpython2.4 hash.c -o hash.so
$ python -c 'import hash'
-1969371895

Pyrex assumes that PyObject_Hash returns an int, but it actually returns a long. The attached patch fixes this problem.

--
Jakub Wilk
diff -ur pyrex-0.9.6.4.orig/Pyrex/Compiler/Builtin.py pyrex-0.9.6.4/Pyrex/Compiler/Builtin.py
--- pyrex-0.9.6.4.orig/Pyrex/Compiler/Builtin.py	2007-10-16 01:52:31.000000000 +0200
+++ pyrex-0.9.6.4/Pyrex/Compiler/Builtin.py	2008-04-20 13:20:16.000000000 +0200
@@ -20,7 +20,7 @@
     ('getattr',    "OO",   "O",     "PyObject_GetAttr"),
     ('getattr3',   "OOO",  "O",     "__Pyx_GetAttr3",       "getattr"),
     ('hasattr',    "OO",   "i",     "PyObject_HasAttr"),
-    ('hash',       "O",    "i",     "PyObject_Hash"),
+    ('hash',       "O",    "l",     "PyObject_Hash"),
     #('hex',       "",     "",      ""),
     #('id',        "",     "",      ""),
     #('input',     "",     "",      ""),

Reply via email to