[issue10391] obj2ast's error handling can lead to python crashing with a C-level assertion failure

2010-11-19 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

r86538

--
resolution:  - fixed
status: open - closed

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



[issue10391] obj2ast's error handling can lead to python crashing with a C-level assertion failure

2010-11-11 Thread Dave Malcolm

New submission from Dave Malcolm dmalc...@redhat.com:

In various places within the generated Python/Python-ast.c, error handling 
generates a repr() and raises exceptions accordingly.

Currently in py3k the generated code uses PyBytes_AS_STRING() on the repr.  My 
understanding is that repr() should be a PyUnicodeObject, not a PyBytesObject.  
This seems to be unchanged from r63682, which was a mass-change of PyString to 
PyBytes from 2 years ago.

This leads to a python crashing with an assertion failure:
test_compile_ast (__main__.TestSpecifics) ... python: Python/Python-ast.c:5835: 
obj2ast_expr: Assertion `((PyObject*)(tmp))-ob_type))-tp_flags  
((1L27))) != 0)' failed.

when invoking compile() on certain (malformed) trees of ast objects.

--
components: Interpreter Core
messages: 120967
nosy: dmalcolm
priority: normal
severity: normal
status: open
title: obj2ast's error handling can lead to python crashing with a C-level 
assertion failure
type: crash
versions: Python 3.1, Python 3.2, Python 3.3

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



[issue10391] obj2ast's error handling can lead to python crashing with a C-level assertion failure

2010-11-11 Thread Dave Malcolm

Dave Malcolm dmalc...@redhat.com added the comment:

The attached patch:
  - extends the ast error-handling selftest with code that triggers this crash 
(on unpatched code)
  - fixes Parser/asdl_c.py to generate code using _PyUnicode_AS_STRING instead
  - contains the generated changes to Python/Python-ast.c

FWIW, it's not clear to what extent _PyUnicode_AS_STRING is deprecated, 
Include/unicodeobject.h currently has:
   *** This API is for interpreter INTERNAL USE ONLY and will likely
   *** be removed or changed for Python 3.1.
but I hope it won't be, it's far too useful.

--
keywords: +patch
stage:  - patch review
Added file: 
http://bugs.python.org/file19572/py3k-issue-10391-fix-ast-error-handling.patch

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



[issue10391] obj2ast's error handling can lead to python crashing with a C-level assertion failure

2010-11-11 Thread Dave Malcolm

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


--
nosy: +benjamin.peterson, brett.cannon, georg.brandl, ncoghlan

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



[issue10391] obj2ast's error handling can lead to python crashing with a C-level assertion failure

2010-11-11 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

IMO a better patch would be to use the %R format specification:
  PyErr_Format(
  PyExc_TypeError, expected some sort of mod, but got %R, obj);
And no need to use PyObject_Repr and the temporary variable!

--
nosy: +amaury.forgeotdarc

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