Friday, September 08, 2006

Pay attention to the new 'with' and 'as' keywords

As of Sept. 6th (revision 51767), Python 2.6 has two new keywords: with and as. Python code that uses either one of these words as a variable name will be in trouble. How do I know that? Because the Twisted unit tests have been failing in the Twisted Pybots buildslave ever since. Actually the issue is not with Twisted code, but with zope.interface, which is one of the Twisted pre-requisites. Here's the offending code:

Traceback (most recent call last):
File "/tmp/Twisted/bin/trial", line 23, in
from twisted.scripts.trial import run
File "/tmp/Twisted/twisted/scripts/", line 10, in
from twisted.application import app
File "/tmp/Twisted/twisted/application/", line 10, in
from twisted.application import service
File "/tmp/Twisted/twisted/application/", line 20, in
from twisted.python import components
File "/tmp/Twisted/twisted/python/", line 37, in
from zope.interface.adapter import AdapterRegistry
File "/tmp/python-buildbot/local/lib/python2.6/site-packages/zope/interface/", line 201
for with, objects in v.iteritems():
SyntaxError: invalid syntax

It would be great if the Zope folks fixed their code so that the Twisted tests will start passing again. This issue actually impacts all packages that depend on zope.interface -- for example zanshin, which also fails in the Pybots buildslave for the OSAF libraries (graciously set up by Bear from OSAF).

If you're interested in following such issues as they arise in the Pybots buildbot farm, I encourage you to subscribe to the Pybots mailing list.


I mentioned the 'with' keyword already causing problems. As it turns out, Seo Sanghyeon's buildslave, which is running tests for docutils and roundup, uncovered an issue in roundup, related to the 'as' keyword:

Traceback (most recent call last):
File "", line 889, in
File "", line 879, in process_args
bad = main(module_filter, test_filter, libdir)
File "", line 671, in main
runner(files, test_filter, debug)
File "", line 585, in runner
s = get_suite(file)
File "", line 497, in get_suite
mod = package_import(modname)
File "", line 489, in package_import
mod = __import__(modname)
File "/home/buildslave/pybots/roundup/./test/", line 6, in
from roundup import hyperdb
File "/home/buildslave/pybots/roundup/roundup/", line 29, in
import date, password
File "/home/buildslave/pybots/roundup/roundup/", line 735
as = a[0]
SyntaxError: invalid syntax


Benji York said...

This was "fixed" about 4 months ago in the zope.interface trunk. I don't know if any new releases have been made since then, though.

Grig Gheorghiu said...

Cool, thanks for the heads up. Maybe it's time for a new release :-)

glyph said...

Grig, thanks again for setting this up! This is exactly the kind of issue I was hoping would be uncovered.

Grig Gheorghiu said...

Cool! I'm excited to see that Pybots is starting to actually uncover issues :-)

Grig Gheorghiu said...

No, I meant Python 2.6. The checkin was made in the Python trunk, which is 2.6. The 2.5 branch is tested against separately.



Anonymous said...

Great blog - I'v really enjoyed your articles!

You may want to check on your RSS feed, is producing an error... :-(

Grig Gheorghiu said...

Anonymous -- thanks for the tip on atom.xml. I fixed it, so it should work now.

Modifying EC2 security groups via AWS Lambda functions

One task that comes up again and again is adding, removing or updating source CIDR blocks in various security groups in an EC2 infrastructur...