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: _string: formatter_field_name_split() and formatter_parser() don't check input type
Type: crash Stage: resolved
Components: Extension Modules Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: benjamin.peterson, eric.smith, georg.brandl, vstinner
Priority: release blocker Keywords: patch

Created on 2011-01-27 23:07 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
_string.patch vstinner, 2011-01-27 23:07
_string0.patch eric.smith, 2011-01-28 12:06
Messages (8)
msg127236 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-01-27 23:07
$ ./python 
Python 3.2rc1+ (unknown, Jan 18 2011, 00:55:20) 
>>> import _string
>>> _string.formatter_field_name_split(1)
python: Objects/stringlib/string_format.h:1347: formatter_field_name_split: Assertion `((((((PyObject*)(self))->ob_type))->tp_flags & ((1L<<28))) != 0)' failed.
Abandon

$ ./python 
Python 3.2rc1+ (unknown, Jan 18 2011, 00:55:20) 
>>> import _string
>>> _string.formatter_parser(1)
python: Objects/stringlib/string_format.h:1206: formatter_parser: Assertion `((((((PyObject*)(self))->ob_type))->tp_flags & ((1L<<28))) != 0)' failed.
Abandon

Attached patch fixes both crashes and add tests on the _string module (which has only these two functions).
msg127240 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-01-28 00:44
I'll review this tomorrow.
msg127292 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-01-28 12:06
The patch looks good to me. I've added some more tests to cover some corner cases.

Go ahead and commit it.
msg127360 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-01-28 23:27
Release manager: You can decide if this fix should go in before 3.2. It's a trivial fix to a crasher, but it's extremely unlikely anyone would trip over it. It's been a crasher since 3.0.

It's also a crasher in 2.7, although there it's in the str module and the method names have leading underscores.
msg127372 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-01-29 02:55
2011/1/28 Eric Smith <report@bugs.python.org>:
>
> Eric Smith <eric@trueblade.com> added the comment:
>
> Release manager: You can decide if this fix should go in before 3.2. It's a trivial fix to a crasher, but it's extremely unlikely anyone would trip over it. It's been a crasher since 3.0.

Fine w/ me.

>
> It's also a crasher in 2.7, although there it's in the str module and the method names have leading underscores.
>
> ----------
> assignee:  -> georg.brandl
> components: +Extension Modules -Library (Lib)
> nosy: +benjamin.peterson, georg.brandl
> priority: normal -> release blocker
> title: _string: formatter_field_name_split() and formatter_parser doesn't check input type -> _string: formatter_field_name_split() and formatter_parser() don't check input type
> versions: +Python 2.7
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue11032>
> _______________________________________
>
msg127387 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-01-29 09:23
I think the canonical message is "expected X, not Y".  Otherwise, fine to commit.
msg127400 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-01-29 11:18
It looks like the canonical message is "expected X, got Y". With that change I've checked it in in r88226. I'll backport.
msg127402 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-01-29 11:30
Actually this error doesn't exist on older versions because these used to be methods on a string. The error was introduced in r85456 (issue 9418) when these became functions in the _string module.

No need to backport.
History
Date User Action Args
2022-04-11 14:57:11adminsetgithub: 55241
2011-01-29 11:30:29eric.smithsetstatus: open -> closed
nosy: georg.brandl, vstinner, eric.smith, benjamin.peterson
messages: + msg127402

resolution: accepted
stage: resolved
2011-01-29 11:18:02eric.smithsetassignee: vstinner -> eric.smith
messages: + msg127400
nosy: georg.brandl, vstinner, eric.smith, benjamin.peterson
2011-01-29 09:23:31georg.brandlsetassignee: georg.brandl -> vstinner
nosy: georg.brandl, vstinner, eric.smith, benjamin.peterson
2011-01-29 09:23:19georg.brandlsetnosy: georg.brandl, vstinner, eric.smith, benjamin.peterson
messages: + msg127387
2011-01-29 02:55:08benjamin.petersonsetnosy: georg.brandl, vstinner, eric.smith, benjamin.peterson
messages: + msg127372
2011-01-28 23:27:17eric.smithsetpriority: normal -> release blocker

assignee: georg.brandl
components: + Extension Modules, - Library (Lib)

title: _string: formatter_field_name_split() and formatter_parser doesn't check input type -> _string: formatter_field_name_split() and formatter_parser() don't check input type
nosy: + georg.brandl, benjamin.peterson
versions: + Python 2.7
messages: + msg127360
2011-01-28 23:17:35eric.smithsettype: crash
2011-01-28 12:06:43eric.smithsetfiles: + _string0.patch

messages: + msg127292
2011-01-28 00:44:16eric.smithsetnosy: + eric.smith
messages: + msg127240
2011-01-27 23:07:54vstinnercreate