mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
Merge pull request #5275 from tchaikov/wip-12287
pybind/ceph_argparse: do not choke on non-ascii prefix Reviewed-by: Loic Dachary <ldachary@redhat.com>
This commit is contained in:
commit
5ecf3b06cd
@ -513,6 +513,13 @@ class CephPrefix(CephArgtype):
|
||||
self.prefix = prefix
|
||||
|
||||
def valid(self, s, partial=False):
|
||||
try:
|
||||
# `prefix` can always be converted into unicode when being compared,
|
||||
# but `s` could be anything passed by user.
|
||||
s = unicode(s)
|
||||
except UnicodeDecodeError:
|
||||
raise ArgumentPrefix("no match for {0}".format(s))
|
||||
|
||||
if partial:
|
||||
if self.prefix.startswith(s):
|
||||
self.val = s
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/nosetests --nocapture
|
||||
# -*- mode:python; tab-width:4; indent-tabs-mode:t -*-
|
||||
# vim: ts=4 sw=4 smarttab expandtab
|
||||
# -*- mode:python; tab-width:4; indent-tabs-mode:t; coding:utf-8 -*-
|
||||
# vim: ts=4 sw=4 smarttab expandtab fileencoding=utf-8
|
||||
#
|
||||
# Ceph - scalable distributed file system
|
||||
#
|
||||
@ -86,6 +86,15 @@ class TestArgparse:
|
||||
'toomany']))
|
||||
|
||||
|
||||
class TestBasic:
|
||||
|
||||
def test_non_ascii_in_non_options(self):
|
||||
# unicode() is not able to convert this str parameter into unicode
|
||||
# using the default encoding 'ascii'. and validate_command() should
|
||||
# not choke on it.
|
||||
assert_is_none(validate_command(sigdict, ['章鱼和鱿鱼']))
|
||||
|
||||
|
||||
class TestPG(TestArgparse):
|
||||
|
||||
def test_stat(self):
|
||||
|
Loading…
Reference in New Issue
Block a user