Rev 5529: (vila) Catch UnicodeError for optparse parsing (Rory Yorke) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sat Nov 6 16:36:48 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5529 [merge]
revision-id: pqm at pqm.ubuntu.com-20101106163647-vg3eg5y6huqmv6c2
parent: pqm at pqm.ubuntu.com-20101106160148-8maemz21jbrhpzky
parent: v.ladeuil+lp at free.fr-20101106153200-r2uoqbrp15xdj3vv
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2010-11-06 16:36:47 +0000
message:
(vila) Catch UnicodeError for optparse parsing (Rory Yorke)
modified:
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/tests/blackbox/test_exceptions.py test_exceptions.py-20060604211237-yi2cxg0ose3xk4id-1
doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2010-10-08 06:22:30 +0000
+++ b/bzrlib/commands.py 2010-10-29 17:07:42 +0000
@@ -815,7 +815,13 @@
else:
args = argv
- options, args = parser.parse_args(args)
+ # for python 2.5 and later, optparse raises this exception if a non-ascii
+ # option name is given. See http://bugs.python.org/issue2931
+ try:
+ options, args = parser.parse_args(args)
+ except UnicodeEncodeError,e:
+ raise errors.BzrCommandError('Only ASCII permitted in option names')
+
opts = dict([(k, v) for k, v in options.__dict__.iteritems() if
v is not option.OptionParser.DEFAULT_VALUE])
return args, opts
=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- a/bzrlib/tests/blackbox/test_exceptions.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/blackbox/test_exceptions.py 2010-11-06 15:32:00 +0000
@@ -48,6 +48,18 @@
self.assertContainsRe(err, r'Bazaar has encountered an internal error')
+class TestOptParseBugHandling(TestCase):
+ "Test that we handle http://bugs.python.org/issue2931"
+
+ def test_nonascii_optparse(self):
+ """Reasonable error raised when non-ascii in option name"""
+ if sys.version_info < (2,5):
+ error_re = 'no such option'
+ else:
+ error_re = 'Only ASCII permitted in option names'
+ out = self.run_bzr_error([error_re], ['st',u'-\xe4'])
+
+
class TestDeprecationWarning(tests.TestCaseWithTransport):
"""The deprecation warning is controlled via a global variable:
repository._deprecation_warning_done. As such, it can be emitted only once
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2010-11-06 15:26:49 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2010-11-06 15:32:00 +0000
@@ -33,6 +33,8 @@
.. Fixes for situations where bzr would previously crash or give incorrect
or undesirable results.
+* Report error if non-ASCII command option given. (Rory Yorke, #140563)
+
Documentation
*************
@@ -53,6 +55,10 @@
Testing
*******
+.. Fixes and changes that are only relevant to bzr's test framework and
+ suite. This can include new facilities for writing tests, fixes to
+ spurious test failures and changes to the way things should be tested.
+
* Blank output section in scriptrunner tests no longer match any output.
Instead, use '...' as a wildcard if you don't care about the output.
(Martin Pool, #637830)
More information about the bazaar-commits
mailing list