Issue15801
Created on 2012-08-28 21:06 by eallik, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| py274_str_mod_bug.py | Thomas.Waldmann, 2013-03-24 03:04 | |||
| Messages (11) | |||
|---|---|---|---|
| msg169300 - (view) | Author: Erik Allik (eallik) | Date: 2012-08-28 21:06 | |
>>> class Foo(object): ... pass ... >>> "asdads" % Foo() 'asdads' Doesn't look like it's supposed to be this way. As per the documentation: "If format requires a single argument, values may be a single non-tuple object. [5] Otherwise, values must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary)." Tested and confirmed on 2.5, 2.6, 2.7 (both old and new style classes) and 3.2. |
|||
| msg169301 - (view) | Author: Alex Gaynor (alex) * ![]() |
Date: 2012-08-28 21:07 | |
Additional detail, if and only if Foo defines an __str__ method, this raises an exception. |
|||
| msg169302 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2012-08-28 21:16 | |
That doesn't appear to be true in 3.2. I happened to test this on email.message.Message, and it also did not raise an error, but it defines an __str__. I suspect this is some oddball result of the coercion rules. |
|||
| msg169303 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2012-08-28 21:19 | |
Didn't get an error in 2.7, either, with Message(). |
|||
| msg169304 - (view) | Author: Mike Graham (Mike.Graham) | Date: 2012-08-28 21:27 | |
Line 13464 of unicodeobject.c is
if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) &&
!PyUnicode_Check(args))
Too lazy to check, but don't user-created types have a tp_as_mapping? If so, I think it mistakes Foo() for a dict.
|
|||
| msg169309 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2012-08-28 22:02 | |
New changeset 2801bf875a24 by Benjamin Peterson in branch '2.7': use the stricter PyMapping_Check (closes #15801) http://hg.python.org/cpython/rev/2801bf875a24 New changeset 4d431e719646 by Benjamin Peterson in branch '3.2': use the stricter PyMapping_Check (closes #15801) http://hg.python.org/cpython/rev/4d431e719646 New changeset 263d09ce3e9e by Benjamin Peterson in branch 'default': merge 3.2 (#15801) http://hg.python.org/cpython/rev/263d09ce3e9e |
|||
| msg169320 - (view) | Author: Erik Allik (eallik) | Date: 2012-08-28 23:29 | |
Respectable reaction time. |
|||
| msg171664 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2012-09-30 19:49 | |
New changeset 8f07ab82de92 by Ezio Melotti in branch '2.7': #15923: fix a mistake in asdl_c.py that resulted in a TypeError after 2801bf875a24 (see #15801). http://hg.python.org/cpython/rev/8f07ab82de92 New changeset cb988d601803 by Ezio Melotti in branch '3.2': #15923: fix a mistake in asdl_c.py that resulted in a TypeError after 2801bf875a24 (see #15801). http://hg.python.org/cpython/rev/cb988d601803 |
|||
| msg185110 - (view) | Author: Thomas Waldmann (Thomas.Waldmann) | Date: 2013-03-24 03:04 | |
gave 2.7.4rc1 a try and was seeing a failing unit test that does not fail with 2.7.3. see the attached file for some minimal code that succeeds on 2.7.3, but not on 2.7.4rc1. it seems to have to do with being a subclass of Exception, it doesn't happen for subclass of object. |
|||
| msg185111 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2013-03-24 03:37 | |
New changeset 391e3a7db1a3 by Benjamin Peterson in branch '2.7': allow any type with __getitem__ to be a mapping for the purposes of % (#15801) http://hg.python.org/cpython/rev/391e3a7db1a3 |
|||
| msg185112 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2013-03-24 03:37 | |
Thanks for the report. Will be fixed in 2.7.4. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:35 | admin | set | github: 60005 |
| 2013-03-24 03:37:40 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg185112 |
| 2013-03-24 03:37:21 | python-dev | set | messages: + msg185111 |
| 2013-03-24 03:04:26 | Thomas.Waldmann | set | files:
+ py274_str_mod_bug.py nosy: + Thomas.Waldmann messages: + msg185110 |
| 2012-09-30 19:49:05 | python-dev | set | messages: + msg171664 |
| 2012-08-28 23:29:25 | eallik | set | messages: + msg169320 |
| 2012-08-28 22:02:25 | python-dev | set | status: open -> closed nosy:
+ python-dev resolution: fixed |
| 2012-08-28 21:27:59 | Mike.Graham | set | nosy:
+ Mike.Graham messages: + msg169304 |
| 2012-08-28 21:19:38 | r.david.murray | set | messages: + msg169303 |
| 2012-08-28 21:16:51 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg169302 |
| 2012-08-28 21:07:57 | alex | set | nosy:
+ alex messages: + msg169301 |
| 2012-08-28 21:06:21 | eallik | create | |

