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
=== modified file 'bzrlib/errors.py'
--- bzrlib/errors.py 2010-06-30 12:03:30 +0000
+++ bzrlib/errors.py 2010-07-09 16:36:48 +0000
@@ -3157,8 +3157,8 @@
31573157
3158class InvalidPattern(BzrError):3158class InvalidPattern(BzrError):
31593159
3160 _fmt = ('Invalid pattern(s) found. %(message)s')3160 _fmt = ('Invalid pattern(s) found. %(msg)s')
31613161
3162 def __init__(self, message):3162 def __init__(self, msg):
3163 self.message = message3163 self.msg = msg
31643164
31653165
=== modified file 'bzrlib/globbing.py'
--- bzrlib/globbing.py 2010-07-08 05:11:16 +0000
+++ bzrlib/globbing.py 2010-07-09 16:36:48 +0000
@@ -217,11 +217,11 @@
217 if match:217 if match:
218 return patterns[match.lastindex -1]218 return patterns[match.lastindex -1]
219 except errors.InvalidPattern, e:219 except errors.InvalidPattern, e:
220 # We can't show the default e.message to the user as thats for220 # We can't show the default e.msg to the user as thats for
221 # the combined pattern we sent to regex. Instead we indicate to221 # the combined pattern we sent to regex. Instead we indicate to
222 # the user that an ignore file needs fixing.222 # the user that an ignore file needs fixing.
223 mutter('Invalid pattern found in regex: %s.', e.message)223 mutter('Invalid pattern found in regex: %s.', e.msg)
224 e.message = "File ~/.bazaar/ignore or .bzrignore contains errors."224 e.msg = "File ~/.bazaar/ignore or .bzrignore contains errors."
225 raise e225 raise e
226 return None226 return None
227227
228228
=== modified file 'bzrlib/osutils.py'
--- bzrlib/osutils.py 2010-07-08 10:34:12 +0000
+++ bzrlib/osutils.py 2010-07-09 16:36:48 +0000
@@ -2184,7 +2184,7 @@
2184 where = ' in ' + where2184 where = ' in ' + where
2185 # despite the name 'error' is a type2185 # despite the name 'error' is a type
2186 raise errors.BzrCommandError('Invalid regular expression%s: %s'2186 raise errors.BzrCommandError('Invalid regular expression%s: %s'
2187 % (where, e.message))2187 % (where, e.msg))
21882188
21892189
2190if sys.platform == "win32":2190if sys.platform == "win32":
21912191
=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- bzrlib/tests/blackbox/test_log.py 2010-06-30 12:03:30 +0000
+++ bzrlib/tests/blackbox/test_log.py 2010-07-09 16:36:48 +0000
@@ -387,6 +387,7 @@
387 self.make_minimal_branch()387 self.make_minimal_branch()
388 out, err = self.run_bzr(['log', '-m', '*'], retcode=3)388 out, err = self.run_bzr(['log', '-m', '*'], retcode=3)
389 self.assertContainsRe(err, "ERROR.*Invalid pattern.*nothing to repeat")389 self.assertContainsRe(err, "ERROR.*Invalid pattern.*nothing to repeat")
390 self.assertNotContainsRe(err, "Unprintable exception")
390 self.assertEqual(out, '')391 self.assertEqual(out, '')
391392
392 def test_log_unsupported_timezone(self):393 def test_log_unsupported_timezone(self):
393394
=== modified file 'bzrlib/tests/test_errors.py'
--- bzrlib/tests/test_errors.py 2010-05-20 18:23:17 +0000
+++ bzrlib/tests/test_errors.py 2010-07-09 16:36:48 +0000
@@ -655,6 +655,11 @@
655 str(err)655 str(err)
656 self.assertEqual(['open_repository'], fake_bzrdir.calls)656 self.assertEqual(['open_repository'], fake_bzrdir.calls)
657657
658 def test_invalid_pattern(self):
659 error = errors.InvalidPattern('Bad pattern msg.')
660 self.assertEqualDiff("Invalid pattern(s) found. Bad pattern msg.",
661 str(error))
662
658663
659class PassThroughError(errors.BzrError):664class PassThroughError(errors.BzrError):
660665
661666
=== modified file 'bzrlib/tests/test_globbing.py'
--- bzrlib/tests/test_globbing.py 2010-06-30 13:49:02 +0000
+++ bzrlib/tests/test_globbing.py 2010-07-09 16:36:48 +0000
@@ -314,7 +314,7 @@
314 patterns = [u'RE:[']314 patterns = [u'RE:[']
315 g = Globster(patterns)315 g = Globster(patterns)
316 e = self.assertRaises(errors.InvalidPattern, g.match, 'foo')316 e = self.assertRaises(errors.InvalidPattern, g.match, 'foo')
317 self.assertContainsRe(e.message, "File.*ignore.*contains errors")317 self.assertContainsRe(e.msg, "File.*ignore.*contains errors")
318318
319319
320class TestExceptionGlobster(TestCase):320class TestExceptionGlobster(TestCase):
321321
=== modified file 'bzrlib/tests/test_lazy_regex.py'
--- bzrlib/tests/test_lazy_regex.py 2010-06-30 13:49:02 +0000
+++ bzrlib/tests/test_lazy_regex.py 2010-07-09 16:36:48 +0000
@@ -70,8 +70,7 @@
70 # As p.match is lazy, we make it into a lambda so its handled70 # As p.match is lazy, we make it into a lambda so its handled
71 # by assertRaises correctly.71 # by assertRaises correctly.
72 e = self.assertRaises(errors.InvalidPattern, lambda: p.match('foo'))72 e = self.assertRaises(errors.InvalidPattern, lambda: p.match('foo'))
73 self.assertEqual(e.message,73 self.assertEqual(e.msg, '"RE:[" unexpected end of regular expression')
74 '"RE:[" unexpected end of regular expression')
7574
7675
77class TestLazyCompile(tests.TestCase):76class TestLazyCompile(tests.TestCase):