If PyObject_REPR changes or gets renamed in Py2.5, I suggest modifying
the implementation so that it returns a newly allocated C pointer rather
one embedded in an inaccessible (unfreeable) PyStringObject. Roughly:
r = PyObject_Repr(o);
if (r == NULL)
return NULL;
s1 = PyObject_AS_STRING(r);
s2 =
Jeremy Hylton wrote:
> It's intended as an internal debugging API. I find it very convenient
> for adding with a printf() here and there, which is how it got added
> long ago. It should really have a comment mentioning that it leaks
> the repr object, and starting with an _ wouldn't be bad either
Ok, then how about prefixing with _, adding a comment saying in big,
bold letters: FOR DEBUGGING PURPOSES ONLY, THIS LEAKS, and only
defining in a debug build?
n
--
On 4/11/06, Jeremy Hylton <[EMAIL PROTECTED]> wrote:
> It's intended as an internal debugging API. I find it very convenient
> for a
It's intended as an internal debugging API. I find it very convenient
for adding with a printf() here and there, which is how it got added
long ago. It should really have a comment mentioning that it leaks
the repr object, and starting with an _ wouldn't be bad either.
Jeremy
On 4/11/06, Neal N
On 4/11/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
>
> > It strikes me that it should not be used, or maybe renamed to
> > _PyObject_REPR.
> > Should removing or renaming it be done in 2.5 or in Py3K?
>
> Since it is intrinsically buggy, I would support removal in Py2.5
+1 on removal. Goog
> I may not be right, but I don't see how this can't help but not free the
> intermediate PyString object.
Good catch.
> It doesn't seem to be used, except for in situations where Python is not
> going
> to continue working
> much longer anyway (specifically, in compile.c and ceval.c.)
Those
I hadn't noticed this macro defined in Include/object.h before:/* Helper for passing objects to printf and the like */#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj))I may not be right, but I don't see how this can't help but not free the intermediate PyString object. It doesn't se