Rev 2501: Workaround for Pyrex <0.9.5 and python >=2.5 incompatibilities. in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 29 16:42:06 BST 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/knit_index_pyrex
------------------------------------------------------------
revno: 2501
revision-id: john at arbash-meinel.com-20070629154156-qqtkp5u94qiwl5ua
parent: john at arbash-meinel.com-20070629153901-nxydiwh8t8ug76yl
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: knit_index_pyrex
timestamp: Fri 2007-06-29 10:41:56 -0500
message:
Workaround for Pyrex <0.9.5 and python >=2.5 incompatibilities.
Before raising an exception, Pyrex checks that it is a valid exception object.
However python 2.5 changed exceptions to be new-style classes, and this
fails the Pyrex 0.9.4 check. Pyrex 0.9.5 has been updated to do it
correctly.
We just set knownFailure in the test suite when this happens.
Note: You still get an exception, just TypeError instead of ValueError or IndexError.
So the code path will still abort, but the user won't get as nice of a message.
modified:
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
-------------- next part --------------
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-06-29 00:31:00 +0000
+++ b/bzrlib/tests/test_knit.py 2007-06-29 15:41:56 +0000
@@ -20,6 +20,7 @@
import difflib
import gzip
import sha
+import sys
from bzrlib import (
errors,
@@ -705,8 +706,16 @@
"a option 0 1 :",
"b option 0 1 4 :" # We don't have a 4th record
])
- self.assertRaises(errors.KnitCorrupt,
- self.get_knit_index, transport, 'filename', 'r')
+ try:
+ self.assertRaises(errors.KnitCorrupt,
+ self.get_knit_index, transport, 'filename', 'r')
+ except TypeError, e:
+ if (str(e) == ('exceptions must be strings, classes, or instances,'
+ ' not exceptions.IndexError')
+ and sys.version_info[0:2] >= (2,5)):
+ self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
+ ' raising new style exceptions with python'
+ ' >=2.5')
def test_corrupted_parent(self):
transport = MockTransport([
@@ -715,18 +724,34 @@
"b option 0 1 :",
"c option 0 1 1v :", # Can't have a parent of '1v'
])
- self.assertRaises(errors.KnitCorrupt,
- self.get_knit_index, transport, 'filename', 'r')
+ try:
+ self.assertRaises(errors.KnitCorrupt,
+ self.get_knit_index, transport, 'filename', 'r')
+ except TypeError, e:
+ if (str(e) == ('exceptions must be strings, classes, or instances,'
+ ' not exceptions.ValueError')
+ and sys.version_info[0:2] >= (2,5)):
+ self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
+ ' raising new style exceptions with python'
+ ' >=2.5')
def test_corrupted_parent_in_list(self):
transport = MockTransport([
_KnitIndex.HEADER,
"a option 0 1 :",
"b option 0 1 :",
- "c option 0 1 2 v :", # Can't have a parent of 'v'
+ "c option 0 1 1 v :", # Can't have a parent of 'v'
])
- self.assertRaises(errors.KnitCorrupt,
- self.get_knit_index, transport, 'filename', 'r')
+ try:
+ self.assertRaises(errors.KnitCorrupt,
+ self.get_knit_index, transport, 'filename', 'r')
+ except TypeError, e:
+ if (str(e) == ('exceptions must be strings, classes, or instances,'
+ ' not exceptions.ValueError')
+ and sys.version_info[0:2] >= (2,5)):
+ self.knownFailure('Pyrex <0.9.5 fails with TypeError when'
+ ' raising new style exceptions with python'
+ ' >=2.5')
class LowLevelKnitIndexTests_c(LowLevelKnitIndexTests):
More information about the bazaar-commits
mailing list