Sümer Cip wrote: > Hi, > > While porting a C extension from 2 to 3, I realized that there are some > general cases which can be automated. For example, for my specific > application (yappi - http://code.google.com/p/yappi/), all I need to do is > following things: > > 1) define PyModuleDef > 2) change PyString_AS_STRING calls to _PyUnicode_AsString
Aside: Please don't use private APIs in Python extensions. Esp. the above Unicode API is likely going to be phased out. You're better off, using PyUnicode_AsUTF8String() instead and then leaving the PyString_AS_STRING() macro in place. > 3) change module init code a little. > > It occurred to me all these kind of standart changes can be automated via a > script. > > Not sure on the usability of this however, because of my limited knowledge > on the area. > > Does such a tool worth being implemented? I'm not sure whether you can really automate this: The change from 8-bit strings to Unicode support usually requires reconsidering whether you're dealing with plain text, encoded text data or binary data. However, a guide of what to replace and how to change the code would probably help a lot. Please share your thoughts on the python-porting mailint list and/or add to these wiki pages: http://wiki.python.org/moin/PortingToPy3k http://wiki.python.org/moin/PortingExtensionModulesToPy3k Thanks, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Mar 03 2011) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com