commit 2d3e8f3c0072f9757eca1836074799191d8d151a Author: David Malcolm dmalcolm@redhat.com Date: Tue Sep 6 14:03:09 2011 -0400
cpychecker: initial implementation of Py_Finalize
libcpychecker/refcounts.py | 8 ++++ .../refcounts/Py_Finalize/correct/input.c | 38 ++++++++++++++++++++ .../refcounts/Py_Finalize/correct/script.py | 22 +++++++++++ .../refcounts/Py_Finalize/correct/stdout.txt | 6 +++ 4 files changed, 74 insertions(+), 0 deletions(-) --- diff --git a/libcpychecker/refcounts.py b/libcpychecker/refcounts.py index 5ee4716..997cd06 100644 --- a/libcpychecker/refcounts.py +++ b/libcpychecker/refcounts.py @@ -932,6 +932,14 @@ class MyState(State): return [t_next]
######################################################################## + # Py_Finalize() + ######################################################################## + def impl_Py_Finalize(self, stmt): + # http://docs.python.org/c-api/init.html#Py_Finalize + # For now, treat it as a no-op: + return [self.mktrans_nop(stmt, 'Py_Finalize')] + + ######################################################################## # Py_InitModule* ######################################################################## def impl_Py_InitModule4_64(self, stmt): diff --git a/tests/cpychecker/refcounts/Py_Finalize/correct/input.c b/tests/cpychecker/refcounts/Py_Finalize/correct/input.c new file mode 100644 index 0000000..7d9b037 --- /dev/null +++ b/tests/cpychecker/refcounts/Py_Finalize/correct/input.c @@ -0,0 +1,38 @@ +/* + Copyright 2011 David Malcolm dmalcolm@redhat.com + Copyright 2011 Red Hat, Inc. + + This is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + http://www.gnu.org/licenses/. +*/ + +#include <Python.h> + +/* + Test of correct call to Py_Finalize: +*/ + +void +test(void) +{ + Py_Finalize(); +} + +/* + PEP-7 +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ diff --git a/tests/cpychecker/refcounts/Py_Finalize/correct/script.py b/tests/cpychecker/refcounts/Py_Finalize/correct/script.py new file mode 100644 index 0000000..fdd5ba3 --- /dev/null +++ b/tests/cpychecker/refcounts/Py_Finalize/correct/script.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2011 David Malcolm dmalcolm@redhat.com +# Copyright 2011 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# http://www.gnu.org/licenses/. + +from libcpychecker import main +main(verify_refcounting=True, + dump_traces=True, + show_traces=False) diff --git a/tests/cpychecker/refcounts/Py_Finalize/correct/stdout.txt b/tests/cpychecker/refcounts/Py_Finalize/correct/stdout.txt new file mode 100644 index 0000000..622f761 --- /dev/null +++ b/tests/cpychecker/refcounts/Py_Finalize/correct/stdout.txt @@ -0,0 +1,6 @@ +Trace 0: + Transitions: + 'calling Py_Finalize()' + 'returning' + Exception: + (struct PyObject *)0 from tests/cpychecker/refcounts/Py_Finalize/correct/input.c:28
gcc-python-plugin-commits@lists.stg.fedorahosted.org