Merge lp:~parthm/bzr/603461-invalidpattern-python25 into lp:bzr

Proposed by Parth Malwankar
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5340
Proposed branch: lp:~parthm/bzr/603461-invalidpattern-python25
Merge into: lp:bzr
Diff against target: 102 lines (+15/-10)
7 files modified
bzrlib/errors.py (+3/-3)
bzrlib/globbing.py (+3/-3)
bzrlib/osutils.py (+1/-1)
bzrlib/tests/blackbox/test_log.py (+1/-0)
bzrlib/tests/test_errors.py (+5/-0)
bzrlib/tests/test_globbing.py (+1/-1)
bzrlib/tests/test_lazy_regex.py (+1/-2)
To merge this branch: bzr merge lp:~parthm/bzr/603461-invalidpattern-python25
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+29587@code.launchpad.net

Commit message

Rename errors.InvalidPattern argument message=>msg to work with multiple Python versions.

Description of the change

=== Fixes Bug #603461 ===
This fixes the regression noted in bug #603461. InvalidPattern was using "message" as the name of its argument and this was causing problems on certain versions of Python (2.5 and 2.6.2). As noted elsewhere in errors.py: "'msg' is used instead of 'message' because python evolved and, in 2.6, forbids the use of 'message'."

This patch renames the argument to "msg" and also adds a test to bt.test_errors

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) 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 'bzrlib/errors.py'
2--- bzrlib/errors.py 2010-06-30 12:03:30 +0000
3+++ bzrlib/errors.py 2010-07-09 16:36:48 +0000
4@@ -3157,8 +3157,8 @@
5
6 class InvalidPattern(BzrError):
7
8- _fmt = ('Invalid pattern(s) found. %(message)s')
9+ _fmt = ('Invalid pattern(s) found. %(msg)s')
10
11- def __init__(self, message):
12- self.message = message
13+ def __init__(self, msg):
14+ self.msg = msg
15
16
17=== modified file 'bzrlib/globbing.py'
18--- bzrlib/globbing.py 2010-07-08 05:11:16 +0000
19+++ bzrlib/globbing.py 2010-07-09 16:36:48 +0000
20@@ -217,11 +217,11 @@
21 if match:
22 return patterns[match.lastindex -1]
23 except errors.InvalidPattern, e:
24- # We can't show the default e.message to the user as thats for
25+ # We can't show the default e.msg to the user as thats for
26 # the combined pattern we sent to regex. Instead we indicate to
27 # the user that an ignore file needs fixing.
28- mutter('Invalid pattern found in regex: %s.', e.message)
29- e.message = "File ~/.bazaar/ignore or .bzrignore contains errors."
30+ mutter('Invalid pattern found in regex: %s.', e.msg)
31+ e.msg = "File ~/.bazaar/ignore or .bzrignore contains errors."
32 raise e
33 return None
34
35
36=== modified file 'bzrlib/osutils.py'
37--- bzrlib/osutils.py 2010-07-08 10:34:12 +0000
38+++ bzrlib/osutils.py 2010-07-09 16:36:48 +0000
39@@ -2184,7 +2184,7 @@
40 where = ' in ' + where
41 # despite the name 'error' is a type
42 raise errors.BzrCommandError('Invalid regular expression%s: %s'
43- % (where, e.message))
44+ % (where, e.msg))
45
46
47 if sys.platform == "win32":
48
49=== modified file 'bzrlib/tests/blackbox/test_log.py'
50--- bzrlib/tests/blackbox/test_log.py 2010-06-30 12:03:30 +0000
51+++ bzrlib/tests/blackbox/test_log.py 2010-07-09 16:36:48 +0000
52@@ -387,6 +387,7 @@
53 self.make_minimal_branch()
54 out, err = self.run_bzr(['log', '-m', '*'], retcode=3)
55 self.assertContainsRe(err, "ERROR.*Invalid pattern.*nothing to repeat")
56+ self.assertNotContainsRe(err, "Unprintable exception")
57 self.assertEqual(out, '')
58
59 def test_log_unsupported_timezone(self):
60
61=== modified file 'bzrlib/tests/test_errors.py'
62--- bzrlib/tests/test_errors.py 2010-05-20 18:23:17 +0000
63+++ bzrlib/tests/test_errors.py 2010-07-09 16:36:48 +0000
64@@ -655,6 +655,11 @@
65 str(err)
66 self.assertEqual(['open_repository'], fake_bzrdir.calls)
67
68+ def test_invalid_pattern(self):
69+ error = errors.InvalidPattern('Bad pattern msg.')
70+ self.assertEqualDiff("Invalid pattern(s) found. Bad pattern msg.",
71+ str(error))
72+
73
74 class PassThroughError(errors.BzrError):
75
76
77=== modified file 'bzrlib/tests/test_globbing.py'
78--- bzrlib/tests/test_globbing.py 2010-06-30 13:49:02 +0000
79+++ bzrlib/tests/test_globbing.py 2010-07-09 16:36:48 +0000
80@@ -314,7 +314,7 @@
81 patterns = [u'RE:[']
82 g = Globster(patterns)
83 e = self.assertRaises(errors.InvalidPattern, g.match, 'foo')
84- self.assertContainsRe(e.message, "File.*ignore.*contains errors")
85+ self.assertContainsRe(e.msg, "File.*ignore.*contains errors")
86
87
88 class TestExceptionGlobster(TestCase):
89
90=== modified file 'bzrlib/tests/test_lazy_regex.py'
91--- bzrlib/tests/test_lazy_regex.py 2010-06-30 13:49:02 +0000
92+++ bzrlib/tests/test_lazy_regex.py 2010-07-09 16:36:48 +0000
93@@ -70,8 +70,7 @@
94 # As p.match is lazy, we make it into a lambda so its handled
95 # by assertRaises correctly.
96 e = self.assertRaises(errors.InvalidPattern, lambda: p.match('foo'))
97- self.assertEqual(e.message,
98- '"RE:[" unexpected end of regular expression')
99+ self.assertEqual(e.msg, '"RE:[" unexpected end of regular expression')
100
101
102 class TestLazyCompile(tests.TestCase):