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 2010年09月14日 17:26 by eric.smith, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue9856_python-3.4.diff | flox, 2011年12月12日 19:55 | review | ||
| Messages (21) | |||
|---|---|---|---|
| msg116413 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2010年09月14日 17:26 | |
In 3.3 the existing PendingDeprecationWarning needs to become a DeprecationWarning. In 3.4 it will become an error. I'll change 3.3 after 3.2 is released. See issue 7994 for the original PendingDeprecationWarning discussion. |
|||
| msg116751 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2010年09月18日 03:23 | |
Perhaps this could be expanded to "Deprecation warnings in 3.3" with release-blocker priority to list all 3.2 PendingDWs. Once changes are made, it could be retitled "Removals in 3.4", with a new "Deprecation warnings in 3.4" added. |
|||
| msg130681 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年03月12日 15:09 | |
New changeset ee259a4f3eee by Eric V. Smith in branch 'default': Issue 9856: Change object.__format__ with a non-empty format string from a PendingDeprecationWarning to a DeprecationWarning. http://hg.python.org/cpython/rev/ee259a4f3eee |
|||
| msg130682 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2011年03月12日 15:14 | |
Next step is to make it a TypeError in 3.4. |
|||
| msg149351 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2011年12月12日 19:55 | |
Patch is ready for python 3.4 :-) |
|||
| msg177970 - (view) | Author: Viktor Ershov (krinart) * | Date: 2012年12月23日 10:28 | |
As I can see this is already implemented in 3.4 |
|||
| msg177977 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年12月23日 12:27 | |
New changeset d91c14788729 by Andrew Svetlov in branch 'default': Issue #9856: Replace deprecation warinigs to raising TypeError in object.__format__ http://hg.python.org/cpython/rev/d91c14788729 |
|||
| msg177981 - (view) | Author: Andrew Svetlov (asvetlov) * (Python committer) | Date: 2012年12月23日 12:42 | |
Committed. Thanks. |
|||
| msg177983 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年12月23日 13:12 | |
New changeset 2f6ec67636b8 by Andrew Svetlov in branch 'default': Add NEWS and docs for #9856 http://hg.python.org/cpython/rev/2f6ec67636b8 |
|||
| msg177984 - (view) | Author: Andrew Svetlov (asvetlov) * (Python committer) | Date: 2012年12月23日 13:19 | |
Updated NEWS and docs |
|||
| msg177992 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2012年12月23日 16:19 | |
The more I think about this, the more overly restrictive I realize it is. If the type of the object really is "object", then it can use string formatting. It's only for non-objects that I want to add the error. I'll re-open it and give it some more thought. |
|||
| msg177994 - (view) | Author: Andrew Svetlov (asvetlov) * (Python committer) | Date: 2012年12月23日 16:28 | |
Ok |
|||
| msg189048 - (view) | Author: Yogesh Chaudhari (Yogesh.Chaudhari) * | Date: 2013年05月12日 17:06 | |
@Eric:
when you say: "If the type of the object really is "object", then it can use string formatting. It's only for non-objects that I want to add the error.".
I am confused. Let me demonstrate what I'm thinking according to the statement above.
First let us take a 'non-object':
>>> integer=1
>>> type(integer) != object
True
As of now it returns the following:
>>> integer.__format__(s)
'1'
Which seems natural.
But after this patch should it return an error
Also now consider an object:
>>> f = object()
>>> type(f)
<class 'object'>
This will return the following after the patch as it does now which is:
>>> f.__format__('')
'<object object at 0xb75b7b48>'
Does this mean that 'integer' should give an error, however, 'f' should give something that appears messy?
I may be mistaken in my interpretation of the statement, so kindly let me know if there is something else that I am not clearly understanding.
|
|||
| msg189049 - (view) | Author: Yogesh Chaudhari (Yogesh.Chaudhari) * | Date: 2013年05月12日 17:07 | |
Please replace
integer.__format__(s)
with
integer.__format__('')
|
|||
| msg189062 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2013年05月12日 20:43 | |
But int has its own __format__ method, so this does not apply. Per the title of this issue, this only refers to object.__format__. For example: This works now, and will continue working: >>> format(2, '1') '2' This is currently an error, and will remain an error: >>> class C: pass ... >>> format(C(), '1') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: non-empty format string passed to object.__format__ It's this case that is currently an error, but it need not be: >>> format(object(), '1') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: non-empty format string passed to object.__format__ The more I think about it, the more I think it would be too confusing to make object.__format__ behave differently if self is of type object, versus another type. So I'll probably just close this as fixed unless someone feels strongly about it. |
|||
| msg189068 - (view) | Author: Yogesh Chaudhari (Yogesh.Chaudhari) * | Date: 2013年05月12日 22:06 | |
>It's this case that is currently an error, but it need not be:
>>>> format(object(), '1')
>Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>TypeError: non-empty format string passed to object.__format__
I believe that should continue to remain an error. Please note that this works
>>> format(object(), '')
'<object object at 0xb74fd688>'
From what I can tell, specifying '1' or '2' or '100' makes no sense because unlike string or int (and like list or tuple ) this 'number' does not represent anything sensible.
This works fine as it should:
>>> format('q', '5')
'q '
>>> format(1, '5')
' 1'
>>> format(1, '05')
'00001'
>>>
But this does not and IMHO *should* not 'work'
>>> format([1,2,3], '5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: non-empty format string passed to object.__format__
>>> format((1,2,3), '5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: non-empty format string passed to object.__format__
an object() CANNOT have specific behavior like str or int. You can of-course argue as to what kind of error/exception/warning this may raise, but it does not make any sense (AFAIK) to 'fix' this.
|
|||
| msg189089 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2013年05月13日 02:07 | |
Everying is an instance of object. If its class does not override .__format__, then it seems that it should act the same as a direct object instance. If this a the current plan (or patch already committed, I think I would stay with that. |
|||
| msg189107 - (view) | Author: Yogesh Chaudhari (Yogesh.Chaudhari) * | Date: 2013年05月13日 08:32 | |
+1 to Terry for "If its class does not override .__format__, then it seems that it should act the same as a direct object instance" |
|||
| msg189586 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2013年05月19日 13:11 | |
Since Eric indicated he'd close this unless someone felt strongly that the status quo should be changed, and the arguments are in favor of *maintaining* the status quo, I'm going to close this for him :) |
|||
| msg205017 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年12月02日 15:29 | |
Perhaps the versionchanged tag for format() is more suitable than versionadded. |
|||
| msg211041 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2014年02月11日 23:34 | |
New changeset f56b98143792 by R David Murray in branch 'default': whatsnew: object.__format__ raises TypeError on non-empty string. http://hg.python.org/cpython/rev/f56b98143792 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:06 | admin | set | github: 54065 |
| 2014年02月11日 23:34:43 | python-dev | set | messages: + msg211041 |
| 2013年12月02日 15:29:40 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg205017 |
| 2013年05月19日 13:11:53 | r.david.murray | set | status: open -> closed nosy: + r.david.murray messages: + msg189586 resolution: fixed stage: resolved |
| 2013年05月13日 08:32:41 | Yogesh.Chaudhari | set | messages: + msg189107 |
| 2013年05月13日 02:07:09 | terry.reedy | set | messages: + msg189089 |
| 2013年05月12日 22:06:22 | Yogesh.Chaudhari | set | messages: + msg189068 |
| 2013年05月12日 20:43:15 | eric.smith | set | messages: + msg189062 |
| 2013年05月12日 17:07:39 | Yogesh.Chaudhari | set | messages: + msg189049 |
| 2013年05月12日 17:06:33 | Yogesh.Chaudhari | set | nosy:
+ Yogesh.Chaudhari messages: + msg189048 |
| 2013年02月16日 06:51:53 | Ankur.Ankan | set | nosy:
+ Ankur.Ankan |
| 2012年12月23日 16:28:46 | asvetlov | set | messages: + msg177994 |
| 2012年12月23日 16:19:25 | eric.smith | set | status: closed -> open resolution: fixed -> (no value) messages: + msg177992 stage: resolved -> (no value) |
| 2012年12月23日 13:19:26 | asvetlov | set | messages: + msg177984 |
| 2012年12月23日 13:12:31 | python-dev | set | messages: + msg177983 |
| 2012年12月23日 12:42:02 | asvetlov | set | status: open -> closed resolution: fixed messages: + msg177981 stage: resolved |
| 2012年12月23日 12:27:27 | python-dev | set | messages: + msg177977 |
| 2012年12月23日 10:28:31 | krinart | set | nosy:
+ krinart, asvetlov messages: + msg177970 |
| 2012年10月26日 10:21:43 | berker.peksag | set | nosy:
- berker.peksag |
| 2012年02月14日 10:51:35 | Arfrever | set | nosy:
+ Arfrever |
| 2011年12月12日 19:55:25 | flox | set | files:
+ issue9856_python-3.4.diff nosy: + flox messages: + msg149351 keywords: + patch |
| 2011年12月12日 13:57:18 | flox | unlink | issue13248 dependencies |
| 2011年12月12日 12:47:27 | flox | link | issue13248 dependencies |
| 2011年12月12日 11:58:53 | berker.peksag | set | nosy:
+ berker.peksag |
| 2011年03月13日 17:47:24 | eric.smith | set | priority: release blocker -> deferred blocker nosy: terry.reedy, eric.smith, python-dev |
| 2011年03月12日 15:14:31 | eric.smith | set | priority: normal -> release blocker versions: + Python 3.4, - Python 3.3 nosy: terry.reedy, eric.smith, python-dev title: Change object.__format__(s) where s is non-empty to a DeprecationWarning -> Change object.__format__(s) where s is non-empty to a TypeError messages: + msg130682 |
| 2011年03月12日 15:09:06 | python-dev | set | nosy:
+ python-dev messages: + msg130681 |
| 2010年09月18日 03:23:01 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg116751 |
| 2010年09月14日 17:26:57 | eric.smith | create | |