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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
3e8693a7
Commit
3e8693a7
authored
4 years ago
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using Py_TYPE and Py_REFCNT macros
parent
45e1d7e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+2
-2
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+3
-3
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
3e8693a7
...
...
@@ -991,6 +991,6 @@ def generate_cypclass_wrapper_allocation(code, wrapper_type):
objstruct_cname
=
wrapper_type
.
objstruct_cname
code
.
putln
(
"if (self) {"
)
code
.
putln
(
"%s * wrapper = (%s *) self;"
%
(
objstruct_cname
,
objstruct_cname
))
code
.
putln
(
"
((PyObject *)wrapper)->ob_refcnt
= 0;"
)
code
.
putln
(
"
((PyObject *)wrapper)->ob_type
= %s;"
%
wrapper_type
.
typeptr_cname
)
code
.
putln
(
"
Py_REFCNT(wrapper)
= 0;"
)
code
.
putln
(
"
Py_TYPE(wrapper)
= %s;"
%
wrapper_type
.
typeptr_cname
)
code
.
putln
(
"}"
)
This diff is collapsed.
Click to expand it.
Cython/Utility/CyObjects.cpp
View file @
3e8693a7
...
...
@@ -186,7 +186,7 @@
}
PyObject
*
ob
=
reinterpret_cast
<
PyObject
*>
(
static_cast
<
CyPyObject
*>
(
cy
));
// artificial atomic increment the first time Python gets a reference
if
(
ob
->
ob_refcnt
==
0
)
if
(
Py_REFCNT
(
ob
)
==
0
)
cy
->
CyObject_INCREF
();
// return a new Python reference
Py_INCREF
(
ob
);
...
...
@@ -208,8 +208,8 @@
template
<
typename
U
>
static
inline
U
*
__Pyx_PyObject_AsCyObject
(
PyObject
*
ob
,
PyTypeObject
*
type
)
{
// the PyObject is not of the expected type
if
(
!
PyType_IsSubtype
(
ob
->
ob_type
,
type
)
)
{
PyErr_Format
(
PyExc_TypeError
,
"Cannot convert PyObject %s to CyObject %s"
,
ob
->
ob_type
->
tp_name
,
type
->
tp_name
);
if
(
!
PyType_IsSubtype
(
Py_TYPE
(
ob
)
,
type
)
)
{
PyErr_Format
(
PyExc_TypeError
,
"Cannot convert PyObject %s to CyObject %s"
,
Py_TYPE
(
ob
)
->
tp_name
,
type
->
tp_name
);
return
NULL
;
}
...
...
This diff is collapsed.
Click to expand it.
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