Refs #28502 -- Complemented stringformat tuple handling/test.

An additional test and a code change were suggested in a late review.
This commit is contained in:
Claude Paroz 2017-08-22 14:45:08 +02:00 committed by Tim Graham
parent 7bba82453c
commit ed77bea582
3 changed files with 5 additions and 2 deletions

View File

@ -223,9 +223,9 @@ def stringformat(value, arg):
See https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting
for documentation of Python string formatting.
"""
if isinstance(value, tuple):
value = str(value)
try:
if isinstance(value, tuple):
return ('%' + str(arg)) % str(value)
return ("%" + str(arg)) % value
except (ValueError, TypeError):
return ""

View File

@ -13,3 +13,5 @@ Bugfixes
in GEOS 3.6.2) (:ticket:`28441`).
* Fixed test database creation with ``cx_Oracle`` 6 (:ticket:`28498`).
* Fixed select widget rendering when option values are tuples (:ticket:`28502`).

View File

@ -39,3 +39,4 @@ class FunctionTests(SimpleTestCase):
self.assertEqual(stringformat(1, 'z'), '')
self.assertEqual(stringformat(object(), 'd'), '')
self.assertEqual(stringformat(None, 'd'), '')
self.assertEqual(stringformat((1, 2, 3), 'd'), '')