[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-python-plugin-commits
Subject:    [gcc-python-plugin] cpychecker: implement PyFile_WriteObject
From:       dmalcolm () fedoraproject ! org (dmalcolm)
Date:       2012-02-29 19:58:05
Message-ID: 20120229195806.27625B9 () lists ! fedorahosted ! org
[Download RAW message or body]

commit 5b9c38fd25af01c5f52c1bf691ec5083c0facd27
Author: David Malcolm <dmalcolm at redhat.com>
Date:   Wed Feb 29 14:57:22 2012 -0500

    cpychecker: implement PyFile_WriteObject

 docs/cpychecker.rst        |    1 +
 libcpychecker/refcounts.py |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/docs/cpychecker.rst b/docs/cpychecker.rst
index 013dffa..525b2ad 100644
--- a/docs/cpychecker.rst
+++ b/docs/cpychecker.rst
@@ -637,6 +637,7 @@ known to the checker are:
 `PyEval_SaveThread <http://docs.python.org/c-api/init.html#PyEval_SaveThread>`_,
 `Py_FatalError <http://docs.python.org/c-api/sys.html#Py_FatalError>`_,
 `PyFile_SoftSpace <http://docs.python.org/c-api/file.html#PyFile_SoftSpace>`_,
+`PyFile_WriteObject <http://docs.python.org/c-api/file.html#PyFile_WriteObject>`_,
 `PyFile_WriteString <http://docs.python.org/c-api/file.html#PyFile_WriteString>`_,
 `Py_Finalize <http://docs.python.org/c-api/init.html#Py_Finalize>`_,
 `PyFrame_New`,
diff --git a/libcpychecker/refcounts.py b/libcpychecker/refcounts.py
index 4a47e59..98fcab0 100644
--- a/libcpychecker/refcounts.py
+++ b/libcpychecker/refcounts.py
@@ -1662,6 +1662,22 @@ class CPython(Facet):
                                               UnknownValue.make(returntype, stmt.loc),
                                               fnmeta.name)]
 
+    def impl_PyFile_WriteObject(self, stmt, v_obj, v_p, v_flags):
+        fnmeta = FnMeta(name='PyFile_WriteObject',
+                        docurl='http://docs.python.org/c-api/file.html#PyFile_WriteObject',
+                        prototype='int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)',
+                        defined_in='Objects/fileobject.c')
+        # used in Cython-generated code, in static int __Pyx_Print()
+        returntype = stmt.fn.type.dereference.type
+
+        # FIXME: gracefully handles NULL for second argument, but not for first
+        s_success = self.state.mkstate_concrete_return_of(stmt, 0)
+        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)
+        # Various errors can happen; this is just one:
+        s_failure.cpython.set_exception('PyExc_IOError', stmt.loc)
+        return self.state.make_transitions_for_fncall(stmt, fnmeta,
+                                                      s_success, s_failure)
+
     def impl_PyFile_WriteString(self, stmt, v_s, v_p):
         fnmeta = FnMeta(name='PyFile_WriteString',
                         docurl='http://docs.python.org/c-api/file.html#PyFile_WriteString',

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic