find_exported_interfaces broken in Python 2.7

Bug #691841 reported by William Grant
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lazr.restful
Fix Released
High
Unassigned
lazr.restful (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

lazr.restful is broken in Python2.7 -- none of the interface entry registrations are processed. A little investigation narrowed this down to find_exported_interfaces' inspect.isclass filter. inspect.isclass(Interface) is True in 2.6, but false in 2.7. 2.6 returns True because Interface.__bases__ exists, but that condition is no longer sufficient in 2.7.

All tests pass in 2.7 with the old isclass implementation, without needing a ZTK upgrade. But I'm not sure what should be done to cleanly solve this.

Tags: python27

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

What can be done to uncleanly solve it?

Changed in lazr.restful:
status: New → Incomplete
importance: Undecided → High
Revision history for this message
Gary Poster (gary) wrote :

On the face of it, this doesn't sound like a tough thing to solve more cleanly. Maybe I'm missing a subtlety. The second argument to inspect.getmembers can be any predicate, so on the face of it something like this should work. http://pastebin.ubuntu.com/553054/

I'll try to give it a whirl tomorrow.

Barry Warsaw (barry)
tags: added: python27
Revision history for this message
Gary Poster (gary) wrote :

Barry, thank you for looking at this. FWIW, I think it is very defensible that inspect.isclass does not return True for a Zope interface. Zope interfaces are made with the class statement, but are really class instances via old-style metaclass trickery, as I'm sure you knew way back when you dealt with this stuff. Therefore, I think that particular issue is not something any upstream should deal with.

I did apply my patch from comment #2. There was a small bug in it (line 19 should have been "tag = member.queryTaggedValue(LAZR_WEBSERVICE_EXPORTED)", but when I fixed it, it made the lazr.restful tests better in Python 2.7 but not without errors. I then tried to upgrade Zope packages to see if that would randomly fix the problem, but it did not.

The next test failure appears to come about because python2.7's httplib.py no longer handles None as a header value in HTTPConnection.putheader (pertinent code was "str = '%s: %s' % (header, value)" and is now "str = '%s: %s' % (header, '\r\n\t'.join(values))"). That looks like a change that could have been more backwards compatible in Python. We can easily accommodate it though. Changing these affected tests is the next thing to do to address this package's Python 2.7 failures. I won't know if it's the last until it's done. :-)

Changed in lazr.restful:
status: Incomplete → Triaged
Revision history for this message
Gary Poster (gary) wrote :

That putheader change was the last one we needed to address for this package. Branch pushed, MP made.

Gary Poster (gary)
Changed in lazr.restful:
status: Triaged → Fix Released
Revision history for this message
Barry Warsaw (barry) wrote :

I'm going to open a separate bug to update to the latest upstream release, but after checking with Gary, we don't think this is necessary for natty.

Changed in lazr.restful (Ubuntu):
status: New → Incomplete
Revision history for this message
Barry Warsaw (barry) wrote :

Bug 759205 is the one for updating the lazr.restful library to 0.18.1, but as described in comment #5, this can wait for oneiric, so I've closed this for now as as Won't Fix in Ubuntu.

Changed in lazr.restful (Ubuntu):
status: Incomplete → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.