Opened 16 years ago

Closed 16 years ago

#1867 defect closed fixed (fixed)

Twisted has numerous problems running with Python 2.5

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: spiv Branch:
Author:

Description

Various behavioral changes in Python 2.5 break assumptions Twisted makes. Many tests fail. Fix them and submit bugs to Python where appropriate.

Change History (18)

comment:1 Changed 16 years ago by Jean-Paul Calderone

(In [17388]) Fix hashability of three classes in Python 2.5

Refs #1842 Refs #1867

Options and RemoteCache basically just want to be hashable by identity: give them an implementation that is almost the same as the previous one, but which truncates to "short" int so that Python does not get upset. We could probably do something which exploited the negative "address space" (hashes are signed) but it seems extremely unlikely that any difference due to this would be noticable in practice.

microdom's Node class has its hash method removed entirely since it was completely superfluous: the Node class defines no custom comparison methods and so instances of Node will only compare equal to themselves, and the default hash is by identity anyway, which is what the implementation being removed was duplicated.

comment:2 Changed 16 years ago by Jean-Paul Calderone

(In [17389]) Suppress deprecation warning for raising a string exception

Refs #1862 Refs #1867

comment:3 Changed 16 years ago by Jean-Paul Calderone

(In [17390]) Refactor testPBFailures into multiple test methods

Refs #1863 Refs #1867

All tested behavior should be the same. The only difference is that each kind of failure is tested in a separate test method.

comment:4 Changed 16 years ago by Jean-Paul Calderone

(In [17391]) Pass absolute path to interpreter as argv[0] in stdio tests

Refs #1864 Refs #1867

Using an absolute path lets Python's import machinery figure out what's going on.

comment:5 Changed 16 years ago by Jean-Paul Calderone

(In [17392]) Use t.p.r.qual to determine exception type names

Refs #1861 Refs #1867

comment:6 Changed 16 years ago by Jean-Paul Calderone

(In [17393]) Add new-style class support to jelly

Refs #1865 Refs #1867

By adjusting security options tracking to use fully qualified Python names and removing the restriction of only handling InstanceType instances which make it all the way to the end of the jelly type-selection logic, instances of new-style classes should now be jellyable. This includes exceptions which may need to be jellied in Python 2.5.

comment:7 Changed 16 years ago by Jean-Paul Calderone

(In [17394]) Add new-style exception support to Failure

Refs #1858 Refs #1859 Refs #1867

Change the type-checks against ClassType to use inspect.isclass() instead and change the str() of exception types to a qual().

comment:8 Changed 16 years ago by Jean-Paul Calderone

(In [17395]) Force mtime and atime to be integers, even if the underlying call gives us floats

Refs #1859 Refs #1867

Float atime and mtime values have been available for a while, but the default has been to continue returning integers. In Python 2.5 the default changes to float. This would be nice to exploit, but for now, just preserve the old behavior exactly.

comment:9 Changed 16 years ago by foom

(In [17402]) Fix for python 2.5 by making same change that was made to ZipFile's read method.

Refs #1867 Refs #1866

comment:10 Changed 16 years ago by foom

(In [17404]) Use reflect.qual on warning class when logging warnings.

Refs #1867

comment:11 Changed 16 years ago by Jonathan Lange

Keywords: review added
Owner: changed from Jean-Paul Calderone to Jonathan Lange

comment:12 Changed 16 years ago by Jonathan Lange

Status: newassigned

comment:13 Changed 16 years ago by spiv

This branch reduces the failing test count on the full-2.5-suse slave from 92 to 12 (and 4 of those are because of #1881), so the sooner this lands the better.

comment:14 Changed 16 years ago by spiv

Cc: spiv added

comment:15 Changed 16 years ago by Stephen Thorne

Keywords: review removed

Quick review of the changes shows pyflakes warnings in some of the modified files.

twisted/python/zipstream.py:33: undefined name 'BadZipfile'
twisted/python/log.py:232: undefined name 'theLogPublisher'
twisted/python/log.py:344: undefined name '_oldshowwarning'
twisted/python/log.py:391: undefined name 'logfile'
twisted/python/log.py:427: undefined name 'defaultObserver'
twisted/conch/unix.py:7: 'util' imported but unused
twisted/conch/unix.py:12: 'OPEN_UNKNOWN_CHANNEL_TYPE' imported but unused
twisted/conch/unix.py:24: redefinition of unused 'os' from line 19
twisted/conch/unix.py:29: redefinition of unused 'utmp' from line 27
twisted/pb/call.py:5: redefinition of unused 'StringIO' from line 3
twisted/pb/call.py:8: 'registerAdapter' imported but unused
twisted/pb/call.py:11: 'remoteinterface' imported but unused
twisted/pb/call.py:12: 'ISlicer' imported but unused
twisted/web/microdom.py:34: 'NodeList' imported but unused
twisted/spread/jelly.py:61: 'sys' imported but unused
twisted/spread/jelly.py:67: redefinition of unused 'UnicodeType' from line 65
twisted/spread/jelly.py:71: 'DictType' imported but unused
twisted/spread/jelly.py:78: 'InstanceType' imported but unused
twisted/spread/jelly.py:91: 'namedModule' imported but unused
twisted/spread/jelly.py:93: 'components' imported but unused
twisted/spread/jelly.py:682: undefined name 'name'

Please verify that these are either spurious pyflakes warnings, or fix them. (The first one is definately a bug, BadZipFile is an exception that doesn't exist).

I've asked the branch to be run on all the buildslaves, not just python2.5, review is also pending that.

Other than requiring that the tests pass on 2.3 and 2.4, I'm happy with this branch, i've gone through and read all the changes and am satisfied with the quality of the code.

comment:16 Changed 16 years ago by jknight

Owner: changed from Jonathan Lange to jknight
Status: assignednew

Exarkun fixed those.

Okay, then. Merging.

comment:17 Changed 16 years ago by foom

Resolution: fixed
Status: newclosed

(In [17448]) Fix almost all python 2.5 issues.

Merging branches/python-two-point-five-1867.

Authors: mostly exarkun, some jknight Reviewer: jml Closes #1867

In detail:

Fix hashability of three classes in Python 2.5: id() now returns only positive numbers, but no longer always short ints, so returning id(self) as hash breaks. Closes #1842

Truncate mtime and atime floats to be integers in conch's unix sftp server implementation. (They changed to be floats by default in python). The interface is still underspecified. Refs #1860.

Fix Newpb failure handling for new-style exceptions. Use t.p.r.qual to determine exception type names. Closes #1861

Suppress deprecation warning for raising a string exception in test_failure.FailureTestCase.testStringExceptions. Closes #1862

Refactor testPBFailures into multiple test methods to make it easier to debug. Closes #1863

Pass absolute path to interpreter as argv[0] in stdio tests. Using an absolute path lets Python's import machinery figure out what's going on. Closes #1864

Add new-style class support to jelly (absolutely necessary because exceptions are now newstyle classes). Closes #1865

Add new-style exception support to Failure. Closes #1858. Closes #1859.

Fix twisted.python.zipstream to account for the removal of file_offset from the ZipInfo class. Closes #1866.

Use reflect.qual on warning class when logging warnings.

comment:18 Changed 11 years ago by <automation>

Owner: jknight deleted
Note: See TracTickets for help on using tickets.