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
c7b3b030
Commit
c7b3b030
authored
Jul 06, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using Py_TYPE and Py_REFCNT macros
parent
95ee4597
Changes
2
Hide 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 @
c7b3b030
...
@@ -991,6 +991,6 @@ def generate_cypclass_wrapper_allocation(code, wrapper_type):
...
@@ -991,6 +991,6 @@ def generate_cypclass_wrapper_allocation(code, wrapper_type):
objstruct_cname
=
wrapper_type
.
objstruct_cname
objstruct_cname
=
wrapper_type
.
objstruct_cname
code
.
putln
(
"if (self) {"
)
code
.
putln
(
"if (self) {"
)
code
.
putln
(
"%s * wrapper = (%s *) self;"
%
(
objstruct_cname
,
objstruct_cname
))
code
.
putln
(
"%s * wrapper = (%s *) self;"
%
(
objstruct_cname
,
objstruct_cname
))
code
.
putln
(
"
((PyObject *)wrapper)->ob_refcnt
= 0;"
)
code
.
putln
(
"
Py_REFCNT(wrapper)
= 0;"
)
code
.
putln
(
"
((PyObject *)wrapper)->ob_type
= %s;"
%
wrapper_type
.
typeptr_cname
)
code
.
putln
(
"
Py_TYPE(wrapper)
= %s;"
%
wrapper_type
.
typeptr_cname
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
Cython/Utility/CyObjects.cpp
View file @
c7b3b030
...
@@ -186,7 +186,7 @@
...
@@ -186,7 +186,7 @@
}
}
PyObject
*
ob
=
reinterpret_cast
<
PyObject
*>
(
static_cast
<
CyPyObject
*>
(
cy
));
PyObject
*
ob
=
reinterpret_cast
<
PyObject
*>
(
static_cast
<
CyPyObject
*>
(
cy
));
// artificial atomic increment the first time Python gets a reference
// artificial atomic increment the first time Python gets a reference
if
(
ob
->
ob_refcnt
==
0
)
if
(
Py_REFCNT
(
ob
)
==
0
)
cy
->
CyObject_INCREF
();
cy
->
CyObject_INCREF
();
// return a new Python reference
// return a new Python reference
Py_INCREF
(
ob
);
Py_INCREF
(
ob
);
...
@@ -208,8 +208,8 @@
...
@@ -208,8 +208,8 @@
template
<
typename
U
>
template
<
typename
U
>
static
inline
U
*
__Pyx_PyObject_AsCyObject
(
PyObject
*
ob
,
PyTypeObject
*
type
)
{
static
inline
U
*
__Pyx_PyObject_AsCyObject
(
PyObject
*
ob
,
PyTypeObject
*
type
)
{
// the PyObject is not of the expected type
// the PyObject is not of the expected type
if
(
!
PyType_IsSubtype
(
ob
->
ob_type
,
type
)
)
{
if
(
!
PyType_IsSubtype
(
Py_TYPE
(
ob
)
,
type
)
)
{
PyErr_Format
(
PyExc_TypeError
,
"Cannot convert PyObject %s to CyObject %s"
,
ob
->
ob_type
->
tp_name
,
type
->
tp_name
);
PyErr_Format
(
PyExc_TypeError
,
"Cannot convert PyObject %s to CyObject %s"
,
Py_TYPE
(
ob
)
->
tp_name
,
type
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
...
...
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