Merge lp:~spiv/bzr/just-add-repr-687653-2.2 into lp:bzr/2.2

Proposed by Andrew Bennetts
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5115
Proposed branch: lp:~spiv/bzr/just-add-repr-687653-2.2
Merge into: lp:bzr/2.2
Diff against target: 28 lines (+7/-0)
2 files modified
NEWS (+4/-0)
bzrlib/errors.py (+3/-0)
To merge this branch: bzr merge lp:~spiv/bzr/just-add-repr-687653-2.2
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+43319@code.launchpad.net

Commit message

Override __repr__ in NotBranchError to avoid side-effects during repr(e).

Description of the change

An simpler alternative to <https://code.launchpad.net/~mbp/bzr/687653-notbrancherror/+merge/43314>. Override __repr__ to make it simple and safe (instead of calling our custom _format which calls open_repository).

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

This is a nice minimal fix for 2.2, and apparently fixes the issue in production.

I think generally we shouldn't have any objects doing real work from their str or repr method, and exceptions should be a lot like value objects.

Perhaps we should have an optional ".hint()" method that the ui can call.

I am kind of inclined to delete this in trunk but it's not really a priority.

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-12-02 09:29:41 +0000
3+++ NEWS 2010-12-10 04:52:57 +0000
4@@ -25,6 +25,10 @@
5 Bug Fixes
6 *********
7
8+* Don't probe for a repository from within ``NotBranchError.__repr__``,
9+ because this can cause knock-on errors at awkward times.
10+ (Andrew Bennetts, #687653)
11+
12 * RevisionTree.is_executable no longer returns None for directories and
13 symlinks. Instead, it returns False, like other Trees and methods.
14 (Aaron Bentley, #681885)
15
16=== modified file 'bzrlib/errors.py'
17--- bzrlib/errors.py 2010-10-11 05:06:26 +0000
18+++ bzrlib/errors.py 2010-12-10 04:52:57 +0000
19@@ -713,6 +713,9 @@
20 self.bzrdir = bzrdir
21 PathError.__init__(self, path=path)
22
23+ def __repr__(self):
24+ return '<%s %r>' % (self.__class__.__name__, self.__dict__)
25+
26 def _format(self):
27 # XXX: Ideally self.detail would be a property, but Exceptions in
28 # Python 2.4 have to be old-style classes so properties don't work.

Subscribers

People subscribed via source and target branches