Merge lp:~gz/bzr/2.3_unprintable_retrywithnewpacks into lp:bzr/2.3

Proposed by Martin Packman
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5664
Proposed branch: lp:~gz/bzr/2.3_unprintable_retrywithnewpacks
Merge into: lp:bzr/2.3
Diff against target: 43 lines (+12/-0)
3 files modified
bzrlib/errors.py (+1/-0)
bzrlib/tests/test_errors.py (+8/-0)
doc/en/release-notes/bzr-2.3.txt (+3/-0)
To merge this branch: bzr merge lp:~gz/bzr/2.3_unprintable_retrywithnewpacks
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+81827@code.launchpad.net

Commit message

Store context argument to RetryWithNewPacks which stops stringification breaking

Description of the change

Merge Andrew's fix for the RetryWithNewPacks exception not being printable, due to missing the context attribute. The exception is not intended to bubble up to users at all, and this doesn't tackle the underlying problem in bug 709349 but may as well be resolved separately now.

Proposing against 2.3 as that's what his branch was, and it's a safe and obvious fix.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Safe and obvious indeed, green light to merge in 2.3 and up to trunk

Just one question:

26 + '{context} {exc value}', str(error))

is error not an exception or is it safe to call str() here ? If the later, I'll warmly welcome some idiot-proof guide on when that's the case ;)

review: Approve
Revision history for this message
Martin Packman (gz) wrote :

> Just one question:
>
> 26 + '{context} {exc value}', str(error))
>
> is error not an exception or is it safe to call str() here ? If the later,
> I'll warmly welcome some idiot-proof guide on when that's the case ;)

Test does look a bit funny, but works with how the code is written currently. Calling str() is okay because we're supplying ascii only inputs - and it's one of our exceptions that has the added robustness when formatting, hence the original 'Unprintable exception' complaint rather than a knock-on KeyError.

Test is in the right place to get updated on bzr.dev when handling of wrapped exceptions is improved.

Revision history for this message
Martin Packman (gz) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/errors.py'
--- bzrlib/errors.py 2011-07-27 11:57:32 +0000
+++ bzrlib/errors.py 2011-11-10 11:06:39 +0000
@@ -1563,6 +1563,7 @@
1563 problem we can raise the original error (value from sys.exc_info())1563 problem we can raise the original error (value from sys.exc_info())
1564 """1564 """
1565 BzrError.__init__(self)1565 BzrError.__init__(self)
1566 self.context = context
1566 self.reload_occurred = reload_occurred1567 self.reload_occurred = reload_occurred
1567 self.exc_info = exc_info1568 self.exc_info = exc_info
1568 self.orig_error = exc_info[1]1569 self.orig_error = exc_info[1]
15691570
=== modified file 'bzrlib/tests/test_errors.py'
--- bzrlib/tests/test_errors.py 2011-01-12 01:01:53 +0000
+++ bzrlib/tests/test_errors.py 2011-11-10 11:06:39 +0000
@@ -712,6 +712,14 @@
712 'Please use `bzr unbind` to fix.')712 'Please use `bzr unbind` to fix.')
713 self.assertEqualDiff(msg, str(error))713 self.assertEqualDiff(msg, str(error))
714714
715 def test_retry_with_new_packs(self):
716 fake_exc_info = ('{exc type}', '{exc value}', '{exc traceback}')
717 error = errors.RetryWithNewPacks(
718 '{context}', reload_occurred=False, exc_info=fake_exc_info)
719 self.assertEqual(
720 'Pack files have changed, reload and retry. context: '
721 '{context} {exc value}', str(error))
722
715723
716class PassThroughError(errors.BzrError):724class PassThroughError(errors.BzrError):
717725
718726
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- doc/en/release-notes/bzr-2.3.txt 2011-09-09 12:32:08 +0000
+++ doc/en/release-notes/bzr-2.3.txt 2011-11-10 11:06:39 +0000
@@ -35,6 +35,9 @@
35* Cope cleanly with buggy HTTP proxies that close the socket in the middle35* Cope cleanly with buggy HTTP proxies that close the socket in the middle
36 of a multipart response. (Martin Pool, #198646).36 of a multipart response. (Martin Pool, #198646).
3737
38* Fix "Unprintable exception" error when a RetryWithNewPacks error is
39 displayed. (Andrew Bennetts)
40
38Documentation41Documentation
39*************42*************
4043

Subscribers

People subscribed via source and target branches