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 changes. So I prefer to keep fprintf.

> 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.

-/* 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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22453>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to