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.

classification
Title: SystemError when formatting int subclass
Type: crash Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ethan.furman Nosy List: barry, eli.bendersky, eric.smith, ethan.furman, ncoghlan, ned.deily, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2013-08-19 14:10 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue18780.stoneleaf.01.patch ethan.furman, 2013-08-28 02:12 review
Messages (14)
msg195631 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-08-19 14:10
>>> class I(int):
...     def __str__(self):
...         return 'spam'
... 
>>> '%i' % (I(42),)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: Objects/unicodeobject.c:13595: bad argument to internal function

This issue is related to issue18738 and will be fixed when use PyNumber_ToBase() for any int subclass (not only for bool).
msg195634 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-08-19 14:36
formatlong() should copy the string if Py_REFCNT(str) != 1.
msg195778 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-08-21 12:03
I think we should just use PyNumber_ToBase() for any int and int subclass. The calling __str__() for special case looks weird.
msg195813 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2013-08-21 18:17
I'll get my patch separated and over here when I get back home (on a business trip at the moment).
msg196343 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2013-08-28 02:12
Okay, simple fix, patch and tests attached.
msg196528 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2013-08-30 12:44
lgtm
msg196652 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-31 17:19
New changeset 33727fbb4668 by Ethan Furman in branch 'default':
Close #18780: %-formatting now prints value for int subclasses with %d, %i, and %u codes.
http://hg.python.org/cpython/rev/33727fbb4668
msg196668 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-31 19:49
New changeset 833246d42825 by Ethan Furman in branch 'default':
Issue #18780: code cleanup.
http://hg.python.org/cpython/rev/833246d42825
msg221461 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2014-06-24 14:49
Should this patch also go into the 3.3 branch?  It only went into 3.4.

If yes, how should I go about doing that?
msg221501 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-06-24 21:29
The 3.3 branch is now only open for security fixes so this issue doesn't appear to warrant backporting there.
msg221504 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2014-06-24 22:02
Cool, leaving it closed.
msg221505 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2014-06-24 22:10
On Tue, Jun 24, 2014 at 2:29 PM, Ned Deily <report@bugs.python.org> wrote:

>
> Ned Deily added the comment:
>
> The 3.3 branch is now only open for security fixes so this issue doesn't
> appear to warrant backporting there.
>
> ----------
>

These questions keep popping up in various places, being asked even by core
devs like here.

Is there a place where this is described formally? I.e. 3.5 is trunk, 3.4
is bug fixes, 3.3 is security fixes, doc fixes good everywhere, and some
info about 2.7? I imagine since this only changes once per 18 months or so,
it should not be difficult to maintain and can just be part of the release
manager's job.
msg221506 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-06-24 22:18
It is described in the developer's guide.  The current status is summarized here:

https://docs.python.org/devguide/devcycle.html#summary
msg221507 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2014-06-24 22:21
On Tue, Jun 24, 2014 at 3:18 PM, Ned Deily <report@bugs.python.org> wrote:

>
> Ned Deily added the comment:
>
> It is described in the developer's guide.  The current status is
> summarized here:
>
> https://docs.python.org/devguide/devcycle.html#summary
>
>
Excellent. Thanks Ned.
History
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 62980
2014-06-24 22:21:58eli.benderskysetmessages: + msg221507
2014-06-24 22:18:20ned.deilysetmessages: + msg221506
2014-06-24 22:10:04eli.benderskysetmessages: + msg221505
2014-06-24 22:02:02ethan.furmansetmessages: + msg221504
versions: - Python 3.3
2014-06-24 21:29:16ned.deilysetnosy: + ned.deily
messages: + msg221501
2014-06-24 14:49:31ethan.furmansetassignee: ethan.furman
messages: + msg221461
2013-08-31 19:49:06python-devsetmessages: + msg196668
2013-08-31 17:19:16python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg196652

resolution: fixed
stage: patch review -> resolved
2013-08-30 12:44:37eli.benderskysetmessages: + msg196528
2013-08-28 02:13:00ethan.furmansetfiles: + issue18780.stoneleaf.01.patch

nosy: + ncoghlan
messages: + msg196343

keywords: + patch
stage: patch review
2013-08-21 18:17:34ethan.furmansetmessages: + msg195813
2013-08-21 13:51:30serhiy.storchakasetnosy: + barry, eric.smith, eli.bendersky, ethan.furman
2013-08-21 12:03:07serhiy.storchakasetmessages: + msg195778
2013-08-19 14:36:16vstinnersetmessages: + msg195634
2013-08-19 14:10:34serhiy.storchakacreate