On 26 August 2010 00:55, Stefan Behnel <[email protected]> wrote: > Lisandro Dalcin, 25.08.2010 22:26: >> On 25 August 2010 17:09, Stefan Behnel wrote: >>> Having it work >>> on .pyx files is IMHO a nice feature that allows users to write their >>> Cython code with the simpler Py3 syntax and semantics, but I doubt that it >>> will be interesting for existing code, so the above can't currently break >>> anything. >> >> What about people wanting to use Py3 syntax and semantics for pyx >> files, but still need to support Python 2 runtimes? > > Are we talking about concrete problems here? >
My concrete problem is that many API's out there do accept 'str', but fail to accept 'unicode'. The 'array' module is an instance of such API's. > >> Are you telling me >> that getattr(obj, "__doc__", None) will not work as expected with >> cython -3 under a Python 2 runtime? > > Works for me. > OK, you are right... because in Python 2 getattr(obj, u"__doc__", None) works as expected, getattr accept both str and unicode. I still think that we should provide a mechanism (likely a compiler directive, off by default) to run -3 but use the behavior of -2 for byte/str/unicode handling (that is, the 'str' type and bare "abc" string literals are PyString in Py2 and PyUnicode in Py3)... As it was suggested, we could even restrict this feature to string literals in the ASCII range. -- Lisandro Dalcin --------------- CIMEC (INTEC/CONICET-UNL) Predio CONICET-Santa Fe Colectora RN 168 Km 472, Paraje El Pozo Tel: +54-342-4511594 (ext 1011) Tel/Fax: +54-342-4511169 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
