mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	merge 3.3
This commit is contained in:
		
						commit
						48953632df
					
				
					 3 changed files with 13 additions and 2 deletions
				
			
		|  | @ -943,6 +943,8 @@ def __format__(self, format_spec): | ||||||
|         self.assertEqual("{0:.0s}".format("ABC\u0410\u0411\u0412"), |         self.assertEqual("{0:.0s}".format("ABC\u0410\u0411\u0412"), | ||||||
|                          '') |                          '') | ||||||
| 
 | 
 | ||||||
|  |         self.assertEqual("{[{}]}".format({"{}": 5}), "5") | ||||||
|  | 
 | ||||||
|     def test_format_map(self): |     def test_format_map(self): | ||||||
|         self.assertEqual(''.format_map({}), '') |         self.assertEqual(''.format_map({}), '') | ||||||
|         self.assertEqual('a'.format_map({}), 'a') |         self.assertEqual('a'.format_map({}), 'a') | ||||||
|  |  | ||||||
|  | @ -13,6 +13,9 @@ Core and Builtins | ||||||
| - Issue #12370: Prevent class bodies from interfering with the __class__ | - Issue #12370: Prevent class bodies from interfering with the __class__ | ||||||
|   closure. |   closure. | ||||||
| 
 | 
 | ||||||
|  | - Issue #17644: Fix a crash in str.format when curly braces are used in square | ||||||
|  |   brackets. | ||||||
|  | 
 | ||||||
| - Issue #17237: Fix crash in the ASCII decoder on m68k. | - Issue #17237: Fix crash in the ASCII decoder on m68k. | ||||||
| 
 | 
 | ||||||
| - Issue #17927: Frame objects kept arguments alive if they had been | - Issue #17927: Frame objects kept arguments alive if they had been | ||||||
|  |  | ||||||
|  | @ -638,7 +638,7 @@ MarkupIterator_next(MarkupIterator *self, SubString *literal, | ||||||
|                     SubString *format_spec, Py_UCS4 *conversion, |                     SubString *format_spec, Py_UCS4 *conversion, | ||||||
|                     int *format_spec_needs_expanding) |                     int *format_spec_needs_expanding) | ||||||
| { | { | ||||||
|     int at_end; |     int at_end, hit_format_spec; | ||||||
|     Py_UCS4 c = 0; |     Py_UCS4 c = 0; | ||||||
|     Py_ssize_t start; |     Py_ssize_t start; | ||||||
|     int count; |     int count; | ||||||
|  | @ -723,11 +723,17 @@ MarkupIterator_next(MarkupIterator *self, SubString *literal, | ||||||
| 
 | 
 | ||||||
|     /* we know we can't have a zero length string, so don't worry
 |     /* we know we can't have a zero length string, so don't worry
 | ||||||
|        about that case */ |        about that case */ | ||||||
|  |     hit_format_spec = 0; | ||||||
|     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 ':': | ||||||
|  |             hit_format_spec = 1; | ||||||
|  |             count = 1; | ||||||
|  |             break; | ||||||
|         case '{': |         case '{': | ||||||
|             /* the format spec needs to be recursively expanded.
 |             /* the format spec needs to be recursively expanded.
 | ||||||
|                this is an optimization, and not strictly needed */ |                this is an optimization, and not strictly needed */ | ||||||
|  |             if (hit_format_spec) | ||||||
|                 *format_spec_needs_expanding = 1; |                 *format_spec_needs_expanding = 1; | ||||||
|             count++; |             count++; | ||||||
|             break; |             break; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson