mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
fix format spec recursive expansion (closes #19729)
This commit is contained in:
parent
bb65b5bf1d
commit
0ee22bf774
3 changed files with 7 additions and 2 deletions
|
@ -955,6 +955,7 @@ class UnicodeTest(string_tests.CommonTest,
|
||||||
'')
|
'')
|
||||||
|
|
||||||
self.assertEqual("{[{}]}".format({"{}": 5}), "5")
|
self.assertEqual("{[{}]}".format({"{}": 5}), "5")
|
||||||
|
self.assertEqual("0x{:0{:d}X}".format(0x0,16), "0x0000000000000000")
|
||||||
|
|
||||||
def test_format_map(self):
|
def test_format_map(self):
|
||||||
self.assertEqual(''.format_map({}), '')
|
self.assertEqual(''.format_map({}), '')
|
||||||
|
|
|
@ -10,6 +10,8 @@ What's New in Python 3.3.4 release candidate 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #19729: In str.format(), fix recursive expansion in format spec.
|
||||||
|
|
||||||
- Issue #19638: Fix possible crash / undefined behaviour from huge (more than 2
|
- Issue #19638: Fix possible crash / undefined behaviour from huge (more than 2
|
||||||
billion characters) input strings in _Py_dg_strtod.
|
billion characters) input strings in _Py_dg_strtod.
|
||||||
|
|
||||||
|
|
|
@ -727,8 +727,10 @@ MarkupIterator_next(MarkupIterator *self, SubString *literal,
|
||||||
while (self->str.start < self->str.end) {
|
while (self->str.start < self->str.end) {
|
||||||
switch (c = PyUnicode_READ_CHAR(self->str.str, self->str.start++)) {
|
switch (c = PyUnicode_READ_CHAR(self->str.str, self->str.start++)) {
|
||||||
case ':':
|
case ':':
|
||||||
hit_format_spec = 1;
|
if (!hit_format_spec) {
|
||||||
count = 1;
|
count = 1;
|
||||||
|
hit_format_spec = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '{':
|
case '{':
|
||||||
/* the format spec needs to be recursively expanded.
|
/* the format spec needs to be recursively expanded.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue