This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2014年01月06日 18:16 by Thomas.Robitaille, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg207459 - (view) | Author: Thomas Robitaille (Thomas.Robitaille) | Date: 2014年01月06日 18:16 | |
The following code:
>>> "{0:s}".format([1,2,3])
no longer works in Python 3.4b1, and gives the following exception:
>>> "{0:s}".format([1,2,3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: non-empty format string passed to object.__format__
This worked previously in Python 2.6-3.3:
>>> "{0:s}".format([1,2,3])
'[1, 2, 3]'
If this is a deliberate change, it should be included in the 'What's new in Python 3.4'
|
|||
| msg207464 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2014年01月06日 18:30 | |
See issue 7994 and issue 9856. This behavior has been deprecated for a while, and is now an error. |
|||
| msg207465 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2014年01月06日 18:33 | |
Oops, I missed the "should be documented" part of your message. That's true, and I'll leave this open. But I'll change it to a doc request and assign it accordingly. |
|||
| msg313331 - (view) | Author: Cheryl Sabella (cheryl.sabella) * (Python committer) | Date: 2018年03月06日 15:13 | |
I believe this has been added to the 3.4 What's New already: object.__format__() no longer accepts non-empty format strings, it now raises a TypeError instead. Using a non-empty string has been deprecated since Python 3.2. This change has been made to prevent a situation where previously working (but incorrect) code would start failing if an object gained a __format__ method, which means that your code may now raise a TypeError if you are using an 's' format code with objects that do not have a __format__ method that handles it. See bpo-7994 for background Closing as resolved. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:56 | admin | set | github: 64349 |
| 2018年03月06日 15:13:59 | cheryl.sabella | set | status: open -> closed nosy: + cheryl.sabella messages: + msg313331 resolution: fixed stage: resolved |
| 2014年01月06日 18:33:22 | eric.smith | set | status: closed -> open assignee: eric.smith -> docs@python components: + Documentation, - Interpreter Core title: API breakage in string formatting with :s option -> API change in string formatting with :s option should be documented in What's New. nosy: + docs@python messages: + msg207465 resolution: not a bug -> (no value) |
| 2014年01月06日 18:30:14 | eric.smith | set | status: open -> closed assignee: eric.smith resolution: not a bug messages: + msg207464 |
| 2014年01月06日 18:20:19 | ezio.melotti | set | nosy:
+ larry, eric.smith, ezio.melotti type: behavior |
| 2014年01月06日 18:16:01 | Thomas.Robitaille | create | |