Issue #22453: Warn against the use of leaking macro PyObject_REPR().

This commit is contained in:
Serhiy Storchaka 2014-11-19 00:08:38 +02:00
parent 60fe569673
commit 81f68a7d4b
2 changed files with 16 additions and 12 deletions

View file

@ -572,8 +572,12 @@ PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
PyAPI_FUNC(int) Py_ReprEnter(PyObject *);
PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
/* Helper for passing objects to printf and the like */
#define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
#ifndef Py_LIMITED_API
/* Helper for passing objects to printf and the like.
Leaks refcounts. Don't use it!
*/
#define PyObject_REPR(obj) PyUnicode_AsUTF8(PyObject_Repr(obj))
#endif
/* Flag bits for printing: */
#define Py_PRINT_RAW 1 /* No string quotes etc. */