Archive for June, 2008

Global Python Sprint Weekend in São Paulo 2

Thursday, June 19th, 2008

This weekend (Jun 21st and 22nd) will happen (again) the Global Python Sprint Weekend and one more time our Python User Group (GruPy-SP) will meet to work together.

Our meeting will be held at Google’s São Paulo Office. Thanks Rodolpho and Google :-)

If you are in São Paulo you can take a look at our wiki (portuguese only) to see how you can join us. If you are not in São Paulo but in Brazil visit the PythonBugDay page to see if anyone in your town is organizing a meet too ;-)

ImportWarning, UnicodeWarning, -W and parser

Wednesday, June 18th, 2008

After almost three weeks (more?) I’m back :-)

Well, this week I’ve fixed two small 2.5 features in PyPy.

The first one was UnicodeWarning. From Python’s docs:

…UnicodeWarning is triggered when you attempt to compare a Unicode string and an 8-bit string that can’t be converted to Unicode using the default ASCII encoding…

In PyPy to trigger a Warning when in Interpreter-level you can use the method space.warn, this method, internally, will use the warnings module to trigger the warning properly.

The second was ImportWarning. Again from Python’s docs:

ImportWarning warning is triggered when an import would have picked up a directory as a package but no __init__.py was found

After searching for a while I’ve found the pypy/lib/__buitins__/importing.py file that holds, obviously, pypy importing stuff. I’ve looked to CPython’s implementation to see when I should trigger the ImportWarn and load_part() seemed to be the right place.

The ImportWarning should be silently ignored unless you provide the -Wd command line option but PyPy does not accept the -W option, so I’ve implemented it. It is simple, you just need to append the argument (‘d’ in this case) to the sys.warnoptions list.

While working on this issues I’ve found a bug in the parser when using the 2.5 Grammar. It is raising a SyntaxError when you call a function passing a keyword argument (like f(x=3)). Because of this (and other small bugs) I’ve decided that I will work on the pyparser to make it compatible with the 2.5 Grammar now.