[Python-3000] Compiling 2.x code under 3k (original) (raw)

Tony Lownds tony at PageDNA.com
Sat Jan 13 18:24:46 CET 2007


While compiling psyco under Python 3000, I ran into some issues that
might be of interest.

At the C level:

statichere & staticforward caused the oddest error messages.

The removal of Py_TPFLAGS_HAVE_XXX touched the most places.

I think it be possible to redefine PyType_HasFeature and all of the
old flags in a compatibility header file, something like :

#define PyType_HasFeature(t,f) ((f) && ( ((t)->tp_flags & (f) ) != 0))

nb_divide and nb_nonzero changes popped up a lot too.

At the python level:

Forced absolute imports was the only syntax issue not handled by 2to3.

This wrinkle of absolute imports surprised me:

from .sibling import * File "", line 1 SyntaxError: 'import *' not allowed with 'from .'

This is a Python 3000 behavior:

hash(sys._getframe()) Traceback (most recent call last): File "", line 1, in TypeError: unhashable type: 'frame'

Potentially a bunch of types will become unhashable since this code was removed from PyObject_Hash:

     if (tp->tp_compare == NULL && RICHCOMPARE(tp) == NULL) {
             return _Py_HashPointer(v); /* Use address as hash  

value */ }

I was wondering whether those two behaviors could be changed.

Thanks -Tony



More information about the Python-3000 mailing list