Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
3fd6fdce
Commit
3fd6fdce
authored
Apr 19, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gilnanny + pystate.pxd
parent
1a60a177
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
3 deletions
+99
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-3
Cython/Includes/cpython/__init__.pxd
Cython/Includes/cpython/__init__.pxd
+1
-0
Cython/Includes/cpython/pystate.pxd
Cython/Includes/cpython/pystate.pxd
+88
-0
Cython/Runtime/refnanny.pyx
Cython/Runtime/refnanny.pyx
+5
-0
No files found.
Cython/Compiler/Nodes.py
View file @
3fd6fdce
...
...
@@ -1564,10 +1564,12 @@ class FuncDefNode(StatNode, BlockNode):
# ----- Go back and insert temp variable declarations
tempvardecl_code
.
put_temp_declarations
(
code
.
funcstate
)
if
code
.
funcstate
.
should_declare_error_indicator
:
tempvardecl_code
.
putln
(
"int %s;"
%
Naming
.
lineno_cname
)
tempvardecl_code
.
putln
(
"const char *%s;"
%
Naming
.
filename_cname
)
# Initialize these variables to shut up compiler warnings
tempvardecl_code
.
putln
(
"int %s = 0;"
%
Naming
.
lineno_cname
)
tempvardecl_code
.
putln
(
"const char *%s = NULL;"
%
Naming
.
filename_cname
)
if
code
.
c_line_in_traceback
:
tempvardecl_code
.
putln
(
"int %s;"
%
Naming
.
clineno_cname
)
tempvardecl_code
.
putln
(
"int %s
= 0
;"
%
Naming
.
clineno_cname
)
# ----- Python version
code
.
exit_cfunc_scope
()
...
...
Cython/Includes/cpython/__init__.pxd
View file @
3fd6fdce
...
...
@@ -146,6 +146,7 @@ from cpython.method cimport *
from
cpython.weakref
cimport
*
from
cpython.getargs
cimport
*
from
cpython.pythread
cimport
*
from
cpython.pystate
cimport
*
# Python <= 2.x
from
cpython.cobject
cimport
*
...
...
Cython/Includes/cpython/pystate.pxd
0 → 100644
View file @
3fd6fdce
# Thread and interpreter state structures and their interfaces
from
cpython.ref
cimport
PyObject
cdef
extern
from
"Python.h"
:
# We make these an opague types. If the user wants specific attributes,
# they can be declared manually.
ctypedef
struct
PyInterpreterState
:
pass
ctypedef
struct
PyThreadState
:
pass
ctypedef
struct
PyFrameObject
:
pass
# This is not actually a struct, but make sure it can never be coerced to
# an int or used in arithmetic expressions
ctypedef
struct
PyGILState_STATE
# The type of the trace function registered using PyEval_SetProfile() and
# PyEval_SetTrace().
# Py_tracefunc return -1 when raising an exception, or 0 for success.
ctypedef
int
(
*
Py_tracefunc
)(
PyObject
*
,
PyFrameObject
*
,
int
,
PyObject
*
)
# The following values are used for 'what' for tracefunc functions
enum
:
PyTrace_CALL
PyTrace_EXCEPTION
PyTrace_LINE
PyTrace_RETURN
PyTrace_C_CALL
PyTrace_C_EXCEPTION
PyTrace_C_RETURN
PyInterpreterState
*
PyInterpreterState_New
()
void
PyInterpreterState_Clear
(
PyInterpreterState
*
)
void
PyInterpreterState_Delete
(
PyInterpreterState
*
)
PyThreadState
*
PyThreadState_New
(
PyInterpreterState
*
)
void
PyThreadState_Clear
(
PyThreadState
*
)
void
PyThreadState_Delete
(
PyThreadState
*
)
PyThreadState
*
PyThreadState_Get
()
PyThreadState
*
PyThreadState_Swap
(
PyThreadState
*
)
PyObject
*
PyThreadState_GetDict
()
int
PyThreadState_SetAsyncExc
(
long
,
PyObject
*
)
# Ensure that the current thread is ready to call the Python
# C API, regardless of the current state of Python, or of its
# thread lock. This may be called as many times as desired
# by a thread so long as each call is matched with a call to
# PyGILState_Release(). In general, other thread-state APIs may
# be used between _Ensure() and _Release() calls, so long as the
# thread-state is restored to its previous state before the Release().
# For example, normal use of the Py_BEGIN_ALLOW_THREADS/
# Py_END_ALLOW_THREADS macros are acceptable.
# The return value is an opaque "handle" to the thread state when
# PyGILState_Ensure() was called, and must be passed to
# PyGILState_Release() to ensure Python is left in the same state. Even
# though recursive calls are allowed, these handles can *not* be shared -
# each unique call to PyGILState_Ensure must save the handle for its
# call to PyGILState_Release.
# When the function returns, the current thread will hold the GIL.
# Failure is a fatal error.
PyGILState_STATE
PyGILState_Ensure
()
# Release any resources previously acquired. After this call, Python's
# state will be the same as it was prior to the corresponding
# PyGILState_Ensure() call (but generally this state will be unknown to
# the caller, hence the use of the GILState API.)
# Every call to PyGILState_Ensure must be matched by a call to
# PyGILState_Release on the same thread.
void
PyGILState_Release
(
PyGILState_STATE
)
# Routines for advanced debuggers, requested by David Beazley.
# Don't use unless you know what you are doing!
PyInterpreterState
*
PyInterpreterState_Head
()
PyInterpreterState
*
PyInterpreterState_Next
(
PyInterpreterState
*
)
PyThreadState
*
PyInterpreterState_ThreadHead
(
PyInterpreterState
*
)
PyThreadState
*
PyThreadState_Next
(
PyThreadState
*
)
Cython/Runtime/refnanny.pyx
View file @
3fd6fdce
from
cpython.ref
cimport
PyObject
,
Py_INCREF
,
Py_DECREF
,
Py_XDECREF
from
cpython.exc
cimport
PyErr_Fetch
,
PyErr_Restore
from
cpython.pystate
cimport
PyThreadState_Get
loglevel
=
0
...
...
@@ -80,6 +81,7 @@ cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except N
return
NULL
cdef
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
cdef
PyObject
*
result
=
NULL
PyThreadState_Get
()
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
ctx
=
Context
(
funcname
,
lineno
,
filename
)
...
...
@@ -131,16 +133,19 @@ cdef void GIVEREF(PyObject* ctx, PyObject* p_obj, int lineno):
cdef
void
INCREF
(
PyObject
*
ctx
,
PyObject
*
obj
,
int
lineno
):
if
obj
is
not
NULL
:
Py_INCREF
(
<
object
>
obj
)
PyThreadState_Get
()
GOTREF
(
ctx
,
obj
,
lineno
)
cdef
void
DECREF
(
PyObject
*
ctx
,
PyObject
*
obj
,
int
lineno
):
if
GIVEREF_and_report
(
ctx
,
obj
,
lineno
):
if
obj
is
not
NULL
:
Py_DECREF
(
<
object
>
obj
)
PyThreadState_Get
()
cdef
void
FinishContext
(
PyObject
**
ctx
):
if
ctx
==
NULL
or
ctx
[
0
]
==
NULL
:
return
cdef
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
cdef
object
errors
=
None
PyThreadState_Get
()
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment