mirror of https://github.com/django/django.git
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:
parent
7bba82453c
commit
ed77bea582
|
@ -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 ""
|
||||
|
|
|
@ -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`).
|
||||
|
|
|
@ -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'), '')
|
||||
|
|
Loading…
Reference in New Issue