[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for your report Chris. PyObject_REPR() is used only in Python/compile.c just before calling Py_FatalError(). So refcount leaks doesn't matter in these cases. PyObject_REPR() is expanded to deprecated _PyUnicode_AsString which is not defined if

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread STINNER Victor
STINNER Victor added the comment: PyObject_REPR() is expanded to deprecated _PyUnicode_AsString which is not defined if Py_LIMITED_API is defined. PyObject_REPR() is still defined if Py_LIMITED_API is defined, I just checked. -- nosy: +haypo ___

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PyObject_REPR() is still defined if Py_LIMITED_API is defined, I just checked. But it is expanded to undefined name. So it is not usable in any case. -- ___ Python tracker rep...@bugs.python.org

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread STINNER Victor
STINNER Victor added the comment: PyObject_REPR.patch: the first part looks good to me. For the second part, you can use PySys_FormatStderr() which is more complex but more correct: it formats the string as Unicode and then encode it to stderr encoding. PyUnicode_FromFormatV() is probably

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread STINNER Victor
STINNER Victor added the comment: Serhiy Storchaka wrote: But it is expanded to undefined name. So it is not usable in any case. Ah correct, I didn't notice _PyUnicode_AsString in the expanded result (I checked with gcc -E). When Py_LIMITED_API is set, PyObject_REPR(o) is expanded to

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: PyObject_REPR() is expanded to deprecated _PyUnicode_AsString which is not defined if Py_LIMITED_API is defined. So it is unlikely that third-party code uses it Py_LIMITED_API is the stable ABI. Most third-party code doesn't use it, so it may still use

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: For the second part, you can use PySys_FormatStderr() which is more complex but more correct PySys_FormatStderr() is more heavy function, it depends on working sys.stderr and codecs. Taking into account the lack of tests we should be careful with such

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le 18/11/2014 17:39, Serhiy Storchaka a écrit : Py_LIMITED_API is the stable ABI. Most third-party code doesn't use it, so it may still use PyObject_REPR(). So we should just add a warning? This macro is not documented anywhere. Well we can still remove

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is updated patch. -- Added file: http://bugs.python.org/file37221/PyObject_REPR_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22453 ___diff

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread STINNER Victor
STINNER Victor added the comment: PyObject_REPR_2.patch looks good to me, but it should only be applied to Python 3.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22453 ___

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset e339d75a21d5 by Serhiy Storchaka in branch 'default': Issue #22453: Removed non-documented macro PyObject_REPR(). https://hg.python.org/cpython/rev/e339d75a21d5 -- nosy: +python-dev ___ Python tracker

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset 342a619cdafb by Serhiy Storchaka in branch '3.4': Issue #22453: Warn against the use of leaking macro PyObject_REPR(). https://hg.python.org/cpython/rev/342a619cdafb New changeset 6e26b5291c41 by Serhiy Storchaka in branch '2.7': Issue #22453:

[issue22453] PyObject_REPR macro causes refcount leak

2014-11-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you for your reviews Victor and Antoine. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22453

[issue22453] PyObject_REPR macro causes refcount leak

2014-09-21 Thread Chris Colbert
New submission from Chris Colbert: This is how the macro is defined in object.h: 2.7 /* Helper for passing objects to printf and the like */ #define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj)) 3.4 /* Helper for passing objects to printf and the like */ #define PyObject_REPR(obj)