[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-11-24 Thread Bill Tutt

Bill Tutt added the comment:

I don't suppose this change could make it into 2.7.11 as well?

Thanks,
Bill

--
nosy: +Bill Tutt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-12-16 Thread John Mark Vandenberg

Changes by John Mark Vandenberg :


--
nosy: +jayvdb

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-08 Thread Anthon van der Neut

New submission from Anthon van der Neut:

Since 3.4.1, string.Formatter() accepts empty keys {}. If these are nested they 
give different results from explicitly numbered, where the same arguments 
applied  "".format() give the expected results:

from string import Formatter

f = Formatter()

fmt0 = "X {:<{}} {} X"
fmt1 = "X {0:<{1}} {2} X"

for fmt in [fmt0, fmt1]:
x = f.format(fmt, 'ab', 5, 1)
y = fmt.format(   'ab', 5, 1)
print(x)
print(y)
gives:

X ab5 X
X ab1 X
X ab1 X
X ab1 X
of which the first line is incorrect.

--
components: Library (Lib)
messages: 250253
nosy: anthon
priority: normal
severity: normal
status: open
title: string.Formatter accepts empty fields but displays wrong when nested
type: behavior
versions: Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-08 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-08 Thread Anthon van der Neut

Anthon van der Neut added the comment:

Here is a patch for Python-3.5.0rc3/Lib/test/test_string.py unittests fail:


--- /opt/python/3.5/lib/python3.5/test/test_string.py   2015-09-08 
17:06:07.099197904 +0200
+++ test_string.py  2015-09-08 21:47:01.471634309 +0200
@@ -58,6 +58,8 @@
  'foo{1}{num}{1}'.format(None, 'bar', num=6))
 self.assertEqual(fmt.format('{:^{}}', 'bar', 6),
  '{:^{}}'.format('bar', 6))
+self.assertEqual(fmt.format('{:^{}} {}', 'bar', 6, 'X'),
+ '{:^{}} {}'.format('bar', 6, 'X'))
 self.assertEqual(fmt.format('{:^{pad}}{}', 'foo', 'bar', pad=6),
  '{:^{pad}}{}'.format('foo', 'bar', pad=6))

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-08 Thread Eric V. Smith

Changes by Eric V. Smith :


--
assignee:  -> eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-08 Thread Anthon van der Neut

Anthon van der Neut added the comment:

The problem lies in the recursive call to _vformat which might consume fields 
without name ({}) and increment auto_arg_index, but that
incremented value was not returned to the parent.

Since the line became longer than pep8 allowed I wrapped all of the method call 
arguments to the next line, hope that that's ok.

The patch is against the mercurial repository and works for 3.4.1 upwards.

--
keywords: +patch
Added file: http://bugs.python.org/file40419/25034.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9eae18e8af66 by Eric V. Smith in branch '3.4':
Fixed issue #25034: Fix string.Formatter problem with auto-numbering
https://hg.python.org/cpython/rev/9eae18e8af66

New changeset 65d7b4fd0332 by Eric V. Smith in branch '3.5':
Issue #25034: Merge from 3.4.
https://hg.python.org/cpython/rev/65d7b4fd0332

New changeset aef6365294c8 by Eric V. Smith in branch 'default':
Issue #25034: Merge from 3.5.
https://hg.python.org/cpython/rev/aef6365294c8

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25034] string.Formatter accepts empty fields but displays wrong when nested

2015-09-29 Thread Eric V. Smith

Eric V. Smith added the comment:

Fixed in 3.4, 3.5, and 3.6. Thanks for the bug report and patch! I added you to 
the Misc/ACKS file.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com