[issue15516] exception-handling bug in PyString_Format

2016-04-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a06654ca0134 by Serhiy Storchaka in branch '2.7':
Issue #13410: Fixed a bug in PyUnicode_Format where it failed to properly
https://hg.python.org/cpython/rev/a06654ca0134

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2016-04-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This fixed an issue for str, but not for unicode. See issue13410.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2013-01-02 Thread Tom Tromey

Tom Tromey added the comment:

It does fail without the patch:

test_format
XXX undetected error
test test_format failed -- Traceback (most recent call last):
  File /home/tromey/Space/Python/cpython/Lib/test/test_format.py, line 251, 
in test_format
def test_exc(formatstr, args, exception, excmsg):
  File /home/tromey/Space/Python/cpython/Lib/test/test_format.py, line 240, 
in __int__
raise TestFailed
TestFailed

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2013-01-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 80cfd4caa726 by Benjamin Peterson in branch '2.7':
call PyErr_Clear() when ignoring error from PyNumber_Int (closes #15516)
http://hg.python.org/cpython/rev/80cfd4caa726

--
nosy: +python-dev
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2013-01-02 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Thanks for the patch. For future reference, we use spaces instead of tabs.

--
resolution: fixed - 
stage: committed/rejected - patch review
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2013-01-02 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-12-07 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Hmm, well I dont't think that test will fail without the patch. You probably 
need to add a special function to _testcapi to check if an exception is set 
(PyErr_Occurred()).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-12-06 Thread Tom Tromey

Tom Tromey added the comment:

It sure would.
Here's a new patch.

--
Added file: http://bugs.python.org/file28223/P

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-12-05 Thread Dave Malcolm

Changes by Dave Malcolm dmalc...@redhat.com:


--
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-12-05 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Wouldn't it be easier to write a Python class that raises an error from 
__int__() but succeeds in __long__()?

--
nosy: +benjamin.peterson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-07-31 Thread Tom Tromey

New submission from Tom Tromey:

In gdb we supply a class whose nb_int method can throw
an exception.

A user wrote code like this:

return '%x' % value

... where value was an instance of this class.
This caused funny exception behavior later on.
You can see the original report here:

http://sourceware.org/bugzilla/show_bug.cgi?id=14320

I tracked down the odd behavior to this code in
stringobject.c:PyString_Format:

iobj = PyNumber_Int(v);
if (iobj==NULL) iobj = PyNumber_Long(v);

Here, PyNumber_Int fails and sets the exception.
I think this ought to be cleared before calling
PyNumber_Long.  In our case, PyNumber_Long succeeds,
and the program keeps executing until something happens
to call PyErr_Occurred.

I think this patch ought to fix the problem:

diff -r e0eb7dea245f Objects/stringobject.c
--- a/Objects/stringobject.cMon Jul 30 04:07:49 2012 -0700
+++ b/Objects/stringobject.cTue Jul 31 13:58:07 2012 -0600
@@ -4489,7 +4489,10 @@
 }
 else {
 iobj = PyNumber_Int(v);
-if (iobj==NULL) iobj = PyNumber_Long(v);
+if (iobj==NULL) {
+   PyErr_Clear();
+   iobj = PyNumber_Long(v);
+   }
 }
 if (iobj!=NULL) {
 if (PyInt_Check(iobj)) {

I haven't written a test case yet; David Malcolm suggested I file
a bug here first.

--
components: None
messages: 167043
nosy: tromey
priority: normal
severity: normal
status: open
title: exception-handling bug in PyString_Format
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-07-31 Thread Dave Malcolm

Changes by Dave Malcolm dmalc...@redhat.com:


--
nosy: +dmalcolm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-07-31 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hi, and thank you for reporting. The diagnosis looks good, please proceed and 
add a test case if possible.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15516] exception-handling bug in PyString_Format

2012-07-31 Thread Tom Tromey

Tom Tromey added the comment:

Here is a patch that includes a test case.
The test fails before the stringobject.c patch is applied,
and passes after.

--
Added file: http://bugs.python.org/file26629/P

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15516
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com