mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +03:00
Flag the psycopg_ensure_*() functions as stealing a ref
This commit is contained in:
parent
5f3f35a2c2
commit
a6df55f4e3
|
@ -160,7 +160,7 @@ static double round(double num)
|
|||
#define isinf(x) (!finite((x)) && (x)==(x))
|
||||
#endif
|
||||
|
||||
/* decorator for the gcc cpychecker plugin */
|
||||
/* decorators for the gcc cpychecker plugin */
|
||||
#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)
|
||||
#define CPYCHECKER_RETURNS_BORROWED_REF \
|
||||
__attribute__((cpychecker_returns_borrowed_ref))
|
||||
|
@ -168,4 +168,11 @@ static double round(double num)
|
|||
#define CPYCHECKER_RETURNS_BORROWED_REF
|
||||
#endif
|
||||
|
||||
#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)
|
||||
#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \
|
||||
__attribute__((cpychecker_steals_reference_to_arg(n)))
|
||||
#else
|
||||
#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)
|
||||
#endif
|
||||
|
||||
#endif /* !defined(PSYCOPG_CONFIG_H) */
|
||||
|
|
|
@ -127,10 +127,14 @@ HIDDEN char *psycopg_escape_string(PyObject *conn,
|
|||
const char *from, Py_ssize_t len, char *to, Py_ssize_t *tolen);
|
||||
HIDDEN char *psycopg_escape_identifier_easy(const char *from, Py_ssize_t len);
|
||||
HIDDEN char *psycopg_strdup(const char *from, Py_ssize_t len);
|
||||
HIDDEN PyObject * psycopg_ensure_bytes(PyObject *obj);
|
||||
HIDDEN PyObject * psycopg_ensure_text(PyObject *obj);
|
||||
HIDDEN int psycopg_is_text_file(PyObject *f);
|
||||
|
||||
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1)
|
||||
HIDDEN PyObject * psycopg_ensure_bytes(PyObject *obj);
|
||||
|
||||
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1)
|
||||
HIDDEN PyObject * psycopg_ensure_text(PyObject *obj);
|
||||
|
||||
/* Exceptions docstrings */
|
||||
#define Error_doc \
|
||||
"Base class for error exceptions."
|
||||
|
|
|
@ -139,6 +139,7 @@ psycopg_strdup(const char *from, Py_ssize_t len)
|
|||
*
|
||||
* It is safe to call the function on NULL.
|
||||
*/
|
||||
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1)
|
||||
PyObject *
|
||||
psycopg_ensure_bytes(PyObject *obj)
|
||||
{
|
||||
|
@ -169,6 +170,7 @@ psycopg_ensure_bytes(PyObject *obj)
|
|||
* The function is ref neutral: steals a ref from obj and adds one to the
|
||||
* return value. It is safe to call it on NULL.
|
||||
*/
|
||||
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1)
|
||||
PyObject *
|
||||
psycopg_ensure_text(PyObject *obj)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user