Title: API change in string formatting with :s option should be documented in What's New.
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Thomas.Robitaille, cheryl.sabella, docs@python, eric.smith, ezio.melotti, larry
Priority: normal Keywords:

Created on 2014-01-06 18:16 by Thomas.Robitaille, last changed 2018-03-06 15:13 by cheryl.sabella. 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.
Date User Action Args
2018-03-06 15:13:59cheryl.sabellasetstatus: open -> closed

nosy: + cheryl.sabella
messages: + msg313331

resolution: fixed
stage: resolved
2014-01-06 18:33:22eric.smithsetstatus: 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:14eric.smithsetstatus: open -> closed
assignee: eric.smith
resolution: not a bug
messages: + msg207464
2014-01-06 18:20:19ezio.melottisetnosy: + larry, eric.smith, ezio.melotti
type: behavior
2014-01-06 18:16:01Thomas.Robitaillecreate