[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-09-10 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset fc153d127901361d7fe5f60caa6f41d2b8db0eb0 by Serhiy Storchaka in 
branch '2.7':
[2.7] bpo-34068: iobase_close could call PyObject_SetAttrString with an 
exception set (GH-8282). (GH-8312) (GH-8314)
https://github.com/python/cpython/commit/fc153d127901361d7fe5f60caa6f41d2b8db0eb0


--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> The assertion failure is a little bit "far" from the bug: would it make sense 
> to add "assert(!PyErr_Occurred());" to the entry point of:

This looks like a part of larger issue, and I think it deserves a separate 
issue on the tracker.

See also issue26776.

--
stage: patch review -> resolved

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +7849
stage: resolved -> patch review

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread STINNER Victor


Change by STINNER Victor :


--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread STINNER Victor


STINNER Victor  added the comment:

Python 2.7 also has the io module: it may be good to backport the change to 
Python 2.7 as well, no? I see the same bug in 2.7:

res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
PyObject_SetAttrString(self, "__IOBase_closed", Py_True);
if (res == NULL) {
return NULL;
}

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread STINNER Victor


STINNER Victor  added the comment:

> The assertion failure is a little bit "far" from the bug: would it make sense 
> to add "assert(!PyErr_Occurred());" to the entry point of:

Stefan, Serhiy: any opinion on my idea?

For example, PyObject_HasAttr() can replace and clear the current exception *by 
design*. This function does more or less:

try: obj.attr; return True
except AttributeError: return False

int
PyObject_HasAttr(PyObject *v, PyObject *name)
{
PyObject *res;
if (_PyObject_LookupAttr(v, name, ) < 0) {
PyErr_Clear();
return 0;
}
if (res == NULL) {
return 0;
}
Py_DECREF(res);
return 1;
}

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset cc13016658a9ed86d0b702ab6c251ad5952a952f by Serhiy Storchaka in 
branch '3.6':
bpo-34068: _io__IOBase_close_impl could call _PyObject_SetAttrId with an 
exception set (GH-8282). (GH-8312)
https://github.com/python/cpython/commit/cc13016658a9ed86d0b702ab6c251ad5952a952f


--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread miss-islington


miss-islington  added the comment:


New changeset 6020d98beaf6b9945beb7560f9a1df361e0ba4dd by Miss Islington (bot) 
in branch '3.7':
bpo-34068: _io__IOBase_close_impl could call _PyObject_SetAttrId with an 
exception set (GH-8282)
https://github.com/python/cpython/commit/6020d98beaf6b9945beb7560f9a1df361e0ba4dd


--
nosy: +miss-islington

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +7847

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7845

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-17 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 28f07364f066792ceee93231dbb80ae8ad98b2bb by Serhiy Storchaka 
(Zackery Spytz) in branch 'master':
bpo-34068: _io__IOBase_close_impl could call _PyObject_SetAttrId with an 
exception set (GH-8282)
https://github.com/python/cpython/commit/28f07364f066792ceee93231dbb80ae8ad98b2bb


--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-14 Thread Zackery Spytz


Change by Zackery Spytz :


--
nosy: +ZackerySpytz
versions: +Python 3.6, Python 3.7

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-14 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
pull_requests: +7816
stage:  -> patch review

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-11 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

_PyType_Lookup doesn't set an exception. But if an exception was raised inside, 
it will be cleared, and this will clear an exception if it was raised before 
_PyType_Lookup. assert() is needed for guaranteeing that no exception will be 
lost.

I'm +1 for saving/restoring (or rather chaining) the exception.

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-11 Thread STINNER Victor


STINNER Victor  added the comment:

> res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
> assert(!PyErr_Occurred()); /* < THIS ASSERTION FAILS */

Using this additional assertion, test_io also fails on 
test_flush_error_on_close().

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-11 Thread STINNER Victor


STINNER Victor  added the comment:

Stefan Behnel: "I added this assertion exactly for the purpose of finding this 
kind of bug. It means that some code tried to look up an attribute with a live 
exception set, which previously could swallow the exception in certain 
situations, and even if not, it is always the wrong thing to do."

The assertion failure is a little bit "far" from the bug: would it make sense 
to add "assert(!PyErr_Occurred());" to the entry point of:

* PyObject_HasAttr()
* PyObject_SetAttr()
* PyObject_SetAttrString()
* _PyObject_SetAttrId()
* type_getattro()
* slot_tp_getattr_hook()
* and other similar functions?

A few years ago, I added "assert(!PyErr_Occurred());" to the entry point of C 
functions which can call arbitrary code like _PyEval_EvalFrameDefault(), 
PyObject_Call(), etc. It helped to find many bugs.

--

___
Python tracker 

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



[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-11 Thread STINNER Victor


STINNER Victor  added the comment:

I'm able to reproduce the bug on my Fedora using:

vstinner@apu$ gdb -args ENV/bin/python -m coverage run  --pylib -m test 
--fail-env-changed -uall,-cpu  test_urllib -F
(gdb) run

python: Objects/typeobject.c:3086: _PyType_Lookup: Assertion 
`!PyErr_Occurred()' failed.

Program received signal SIGABRT, Aborted.
0x77093f2b in raise () from /lib64/libc.so.6

(gdb) py-bt
Traceback (most recent call first):
  
  File "/home/vstinner/prog/python/master/Lib/http/client.py", line 405, in 
close
super().close() # set "closed" flag
  File "/home/vstinner/prog/python/master/Lib/traceback.py", line 216, in 
clear_frames
tb.tb_frame.clear()
  File "/home/vstinner/prog/python/master/Lib/unittest/case.py", line 205, in 
__exit__
traceback.clear_frames(tb)
  File "/home/vstinner/prog/python/master/Lib/unittest/case.py", line 178, in 
handle
callable_obj(*args, **kwargs)
  File "/home/vstinner/prog/python/master/Lib/unittest/case.py", line 743, in 
assertRaises
return context.handle('assertRaises', args, kwargs)
  File "/home/vstinner/prog/python/master/Lib/test/test_urllib.py", line 382, 
in test_redirect_limit_independent
"http://something;)
  (...)

(gdb) where
#0  0x77093f2b in raise () from /lib64/libc.so.6
#1  0x7707e561 in abort () from /lib64/libc.so.6
#2  0x7707e431 in __assert_fail_base.cold.0 () from /lib64/libc.so.6
#3  0x7708c692 in __assert_fail () from /lib64/libc.so.6
#4  0x004aa2ea in _PyType_Lookup (type=0xdc1b30, 
name='__IOBase_closed') at Objects/typeobject.c:3086
#5  0x004883ff in _PyObject_GenericSetAttrWithDict (
obj=, 
debuglevel=0, _method='GET', headers=, _headers=[('Location', 
'file://guidocomputer.athome.com:/python/license'), ('Connection', 'close')], 
_unixfrom=None, _payload='', _charset=None, preamble=None, epilogue=None, 
defects=[], _default_type='text/plain') at remote 0x7fffe542f4d0>, msg=<...>, 
version=11, status=302, reason='Found', chunked=False, chunk_left='UNKNOWN', 
length=None, will_close=True, code=302, _finalizing=True) at remote 
0x7fffe581ff50>, name='__IOBase_closed', value=True, dict=0x0) at 
Objects/object.c:1292
#6  0x0048871a in PyObject_GenericSetAttr (
obj=, 
debuglevel=0, _method='GET', headers=, _headers=[('Location', 
'file://guidocomputer.athome.com:/python/license'), ('Connection', 'close')], 
_unixfrom=None, _payload='', _charset=None, preamble=None, epilogue=None, 
defects=[], _default_type='text/plain') at remote 0x7fffe542f4d0>, msg=<...>, 
version=11, status=302, reason='Found', chunked=False, chunk_left='UNKNOWN', 
length=None, will_close=True, code=302, _finalizing=True) at remote 
0x7fffe581ff50>, name='__IOBase_closed', value=True) at Objects/object.c:1340
#7  0x004873a0 in PyObject_SetAttr (
v=, 
debuglevel=0, _method='GET', headers=, _headers=[('Location', 
'file://guidocomputer.athome.com:/python/license'), ('Connection', 'close')], 
_unixfrom=None, _payload='', _charset=None, preamble=None, epilogue=None, 
defects=[], _default_type='text/plain') at remote 0x7fffe542f4d0>, msg=<...>, 
version=11, status=302, reason='Found', chunked=False, chunk_left='UNKNOWN', 
length=None, will_close=True, code=302, _finalizing=True) at remote 
0x7fffe581ff50>, name='__IOBase_closed', value=True) at Objects/object.c:977
#8  0x00486f03 in _PyObject_SetAttrId (
v=, 
debuglevel=0, _method='GET', headers=, _headers=[('Location', 
'file://guidocomputer.athome.com:/python/license'), ('Connection', 'close')], 
_unixfrom=None, _payload='', _charset=None, preamble=None, epilogue=None, 
defects=[], _default_type='text/plain') at remote 0x7fffe542f4d0>, msg=<...>, 
version=11, status=302, reason='Found', chunked=False, chunk_left='UNKNOWN', 
length=None, will_close=True, code=302, _finalizing=True) at remote 
0x7fffe581ff50>, name=0x9d4330 , w=True) at 
Objects/object.c:857
#9  0x00625d9c in _io__IOBase_close_impl (
self=, 
debuglevel=0, _method='GET', headers=, _headers=[('Location', 
'file://guidocomputer.athome.com:/python/license'), ('Connection', 'close')], 
_unixfrom=None, _payload='', _charset=None, preamble=None, epilogue=None, 
defects=[], _default_type='text/plain') at remote 0x7fffe542f4d0>, msg=<...>, 
version=11, status=302, reason='Found', chunked=False, chunk_left='UNKNOWN', 
length=None, will_close=True, code=302, _finalizing=---T---Type ---Type 
---Type ---Type 
 to ---Type ---Type ---T---Type ---Type 
---T---Type  to continue, or q  to quit---
) at remote 0x7fffe581ff50>) at ./Modules/_io/iobase.c:239
#10 0x00627e12 in _io__IOBase_close (
self=, 
debuglevel=0, _method='GET', headers=, _headers=[('Location', 
'file://guidocomputer.athome.com:/python/license'), ('Connection', 'close')], 
_unixfrom=None, _payload='', _charset=None, preamble=None, epilogue=None, 
defects=[], _default_type='text/plain') at remote 0x7fffe542f4d0>, msg=<...>, 
version=11, status=302, reason='Found', 

[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

2018-07-11 Thread STINNER Victor


Change by STINNER Victor :


--
title: Assertion failure in _PyType_Lookup -> traceback.clear_frames(): 
Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

___
Python tracker 

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