The patch is complete, tests and doc... Thanks! It won't apply to py3k, though: python ...
15 years, 7 months ago
(2009-08-25 07:07:20 UTC)
#1
The patch is complete, tests and doc... Thanks!
It won't apply to py3k, though: python 3 does not use FILE* any more.
I suggest to accept any file-like objects (e.g StringIO) and use the "write"
method. But I don't know if calling python code there can interfere with the
garbage collector.
http://codereview.appspot.com/110078/diff/1/4
File Doc/library/gc.rst (right):
http://codereview.appspot.com/110078/diff/1/4#newcode60
Line 60: descriptor to which debugging information will be written. See below
for a
better say: "a file object"
http://codereview.appspot.com/110078/diff/1/6
File Modules/gcmodule.c (right):
http://codereview.appspot.com/110078/diff/1/6#newcode704
Line 704: FILE* file = PyFile_AsFile((PyObject*) debug_output);
PyFile_AsFile does not exist with python 3. (py3 files have no FILE*) Is it
possible to use the 'write' method directly? Or is it forbidden from inside the
garbage collector?
Here is an updated patch. Who can we nosy to get feedback on the appropriateness ...
15 years, 7 months ago
(2009-08-25 10:26:30 UTC)
#2
Here is an updated patch.
Who can we nosy to get feedback on the appropriateness of calling a Python
function inside debug_print?
Thanks :)
http://codereview.appspot.com/110078/diff/1/4
File Doc/library/gc.rst (right):
http://codereview.appspot.com/110078/diff/1/4#newcode60
Line 60: descriptor to which debugging information will be written. See below
for a
On 2009/08/25 07:07:20, amauryfa wrote:
> better say: "a file object"
Done.
http://codereview.appspot.com/110078/diff/1/6
File Modules/gcmodule.c (right):
http://codereview.appspot.com/110078/diff/1/6#newcode704
Line 704: FILE* file = PyFile_AsFile((PyObject*) debug_output);
On 2009/08/25 07:07:20, amauryfa wrote:
> PyFile_AsFile does not exist with python 3. (py3 files have no FILE*) Is it
> possible to use the 'write' method directly? Or is it forbidden from inside
the
> garbage collector?
Done. I am accessing the write method directly in set_debug to minimize the
Python code running in debug_print.
I am not sure If it's safe to call a function from inside the gc: I'm not
qualified enough to answer that question :)
Since we use stream.write now, we can potentially run arbitrary code there. If
it's not safe, is there is any mechanism in py3 that would allow us to use a
vfprintf-like on a file object? To avoid running any Python code at all?
Issue 110078: Add a stream parameter to gc.set_debug
Created 15 years, 7 months ago by nicdumz
Modified 15 years, 7 months ago
Reviewers: amaury
Base URL: http://svn.python.org/view/*checkout*/python/trunk/
Comments: 4