[pypy-svn] r21617 - in pypy/dist/pypy: rpython translator/c/src
pedronis at codespeak.net
pedronis at codespeak.net
Sat Dec 31 21:49:07 CET 2005
Author: pedronis
Date: Sat Dec 31 21:49:06 2005
New Revision: 21617
Modified:
pypy/dist/pypy/rpython/rint.py
pypy/dist/pypy/translator/c/src/pyobj.h
Log:
fix for test_backendoptimized test_uint_switch for Python 2.3.
Before 2.4 PyLong_AsUnsignedLong didn't accept just an int.
Last bit of PyPy hacking for me for 2005.
Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py (original)
+++ pypy/dist/pypy/rpython/rint.py Sat Dec 31 21:49:06 2005
@@ -435,7 +435,7 @@
py_to_ll_conversion_functions = {
UnsignedLongLong: ('RPyLong_AsUnsignedLongLong', lambda pyo: r_ulonglong(pyo._obj.value)),
SignedLongLong: ('RPyLong_AsLongLong', lambda pyo: r_longlong(pyo._obj.value)),
- Unsigned: ('PyLong_AsUnsignedLong', lambda pyo: r_uint(pyo._obj.value)),
+ Unsigned: ('RPyLong_AsUnsignedLong', lambda pyo: r_uint(pyo._obj.value)),
Signed: ('PyInt_AsLong', lambda pyo: int(pyo._obj.value))
}
Modified: pypy/dist/pypy/translator/c/src/pyobj.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/pyobj.h (original)
+++ pypy/dist/pypy/translator/c/src/pyobj.h Sat Dec 31 21:49:06 2005
@@ -221,6 +221,27 @@
#ifndef PYPY_NOT_MAIN_FILE
+#if (PY_VERSION_HEX < 0x02040000)
+
+unsigned long RPyLong_AsUnsignedLong(PyObject *v)
+{
+ if (PyInt_Check(v)) {
+ long val = PyInt_AsLong(v);
+ if (val < 0) {
+ PyErr_SetNone(PyExc_OverflowError);
+ return (unsigned long)-1;
+ }
+ return val;
+ } else {
+ return PyLong_AsUnsignedLong(v);
+ }
+}
+
+#else
+#define RPyLong_AsUnsignedLong PyLong_AsUnsignedLong
+#endif
+
+
unsigned long long RPyLong_AsUnsignedLongLong(PyObject *v)
{
if (PyInt_Check(v))
More information about the Pypy-commit
mailing list