Issue 1810: AST compile() patch (original) (raw)

Created on 2008-01-11 23:58 by thomaslee, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ast-r01.patch thomaslee,2008-01-11 23:58 A(n almost complete) patch implementing this feature
ast.py thomaslee,2008-01-12 00:00 A demonstration of the crash occuring when ast-r01.patch is applied
ast-r02.patch thomaslee,2008-01-13 01:20 Complete patch?
ast-r03.patch thomaslee,2008-03-15 11:01 Updated to apply cleanly against HEAD, still pending review.
Messages (9)
msg59764 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2008-01-11 23:58
This patch against HEAD provides the inverse operations to all the ast2obj_* functions in Python/Python-ast.c: effectively, this allows conversion to & from a PyObject representation of a Python AST. Additionally, it updates the compile() builtin to allow it to compile Python ASTs to bytecode. The patch seems to work for most simple cases, but crashes out with a segfault when trying to compile functions for some reason.
msg59765 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2008-01-12 00:00
Attaching a sample program to demonstrate the crash.
msg59766 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-12 00:03
Georg is working on the AST front.
msg59813 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-01-12 11:15
This is great work! The problem is that ast2obj_object translates NULL values to Py_None, but obj2ast_object doesn't translate that back. This definition fixes your testcase: static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) { if (obj == Py_None) obj = NULL; Py_XINCREF(obj); *out = obj; return 0; }
msg59847 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2008-01-13 01:20
I knew it would be a simple one for somebody who knew what to look for :) Thanks Georg! r02 is the updated patch. Changing the title of the tracker issue to reflect that this *should* be a complete patch now. Any further recommendations?
msg63545 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2008-03-15 10:49
Georg, just a ping: still waiting on a review for this.
msg63546 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2008-03-15 11:00
Updating the patch to apply cleanly against HEAD.
msg63562 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-03-15 19:56
I'll try to handle it this weekend.
msg64630 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-03-28 12:12
So I finally got to this one :) I had to fix a few things, mainly error handling, and a refleak. And I found a refleak in the compiler :) Reviewed and committed in r62004.
History
Date User Action Args
2022-04-11 14:56:29 admin set github: 46135
2008-03-28 12:12:15 georg.brandl set status: open -> closedresolution: acceptedmessages: +
2008-03-22 23:03:55 aronacher set nosy: + aronacher
2008-03-15 19:56:48 georg.brandl set messages: +
2008-03-15 11:01:04 thomaslee set files: + ast-r03.patchmessages: +
2008-03-15 10:49:55 thomaslee set messages: +
2008-01-13 01:20:44 thomaslee set files: + ast-r02.patchmessages: + title: Partial AST compile() patch -> AST compile() patch
2008-01-12 11:15:17 georg.brandl set messages: +
2008-01-12 00:03:24 christian.heimes set priority: normalassignee: georg.brandlmessages: + keywords: + patchnosy: + georg.brandl, christian.heimes
2008-01-12 00:00:36 thomaslee set files: + ast.pymessages: +
2008-01-11 23:58:41 thomaslee create