Rev 2868: #144633 Fix "unprintable error" message for BzrCheckError and others (mbp) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Sep 26 05:10:24 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2868
revision-id: pqm at pqm.ubuntu.com-20070926041021-v62vw12qiba8vi4k
parent: pqm at pqm.ubuntu.com-20070925233221-gwux298mtf2uy53w
parent: mbp at sourcefrog.net-20070926023624-25aievju0yd3m10l
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-09-26 05:10:21 +0100
message:
#144633 Fix "unprintable error" message for BzrCheckError and others (mbp)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
------------------------------------------------------------
revno: 2854.1.3
merged: mbp at sourcefrog.net-20070926023624-25aievju0yd3m10l
parent: mbp at sourcefrog.net-20070926023045-npkv70za15v30w1r
parent: pqm at pqm.ubuntu.com-20070925233221-gwux298mtf2uy53w
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: exception-keyerrors
timestamp: Wed 2007-09-26 12:36:24 +1000
message:
merge trunk
------------------------------------------------------------
revno: 2854.1.2
merged: mbp at sourcefrog.net-20070926023045-npkv70za15v30w1r
parent: mbp at sourcefrog.net-20070925062946-1tlmmt604lf9bllm
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: exception-keyerrors
timestamp: Wed 2007-09-26 12:30:45 +1000
message:
Review feedback on BzrError.message handling
------------------------------------------------------------
revno: 2854.1.1
merged: mbp at sourcefrog.net-20070925062946-1tlmmt604lf9bllm
parent: pqm at pqm.ubuntu.com-20070924212812-g325vvenhnfktgbh
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: exception-keyerrors
timestamp: Tue 2007-09-25 16:29:46 +1000
message:
Fix "unprintable error" message for BzrCheckError and others
=== modified file 'NEWS'
--- a/NEWS 2007-09-25 22:13:08 +0000
+++ b/NEWS 2007-09-26 02:36:24 +0000
@@ -91,6 +91,10 @@
* Fix log against smart server branches that don't support tags.
(James Westby, #140615)
+ * Fix 'unprintable error' message when displaying BzrCheckError and
+ some other exceptions on Python 2.5.
+ (Martin Pool, #144633)
+
* HttpServer and FtpServer need to be closed properly or a listening socket
will remain opened.
(Vincent Ladeuil, #140055)
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-09-13 01:54:49 +0000
+++ b/bzrlib/errors.py 2007-09-26 02:30:45 +0000
@@ -95,7 +95,11 @@
try:
fmt = self._get_format_string()
if fmt:
- s = fmt % self.__dict__
+ d = dict(self.__dict__)
+ # special case: python2.5 puts the 'message' attribute in a
+ # slot, so it isn't seen in __dict__
+ d['message'] = getattr(self, 'message', 'no message')
+ s = fmt % d
# __str__() should always return a 'str' object
# never a 'unicode' object.
if isinstance(s, unicode):
@@ -783,8 +787,8 @@
# New code should prefer to raise specific subclasses
def __init__(self, message):
# Python 2.5 uses a slot for StandardError.message,
- # so use a different variable name
- # so it is exposed in self.__dict__
+ # so use a different variable name. We now work around this in
+ # BzrError.__str__, but this member name is kept for compatability.
self.msg = message
=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py 2007-08-30 08:11:54 +0000
+++ b/bzrlib/tests/test_errors.py 2007-09-25 06:29:46 +0000
@@ -361,6 +361,15 @@
self.assertEqual(
"Container has multiple records with the same name: n\xc3\xa5me",
str(e))
+
+ def test_check_error(self):
+ # This has a member called 'message', which is problematic in
+ # python2.5 because that is a slot on the base Exception class
+ e = errors.BzrCheckError('example check failure')
+ self.assertEqual(
+ "Internal check failed: example check failure",
+ str(e))
+ self.assertTrue(e.internal_error)
class PassThroughError(errors.BzrError):
More information about the bazaar-commits
mailing list