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
Gwenaël Samain
cython
Commits
4ebbe013
Commit
4ebbe013
authored
Dec 30, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix strict aliasing issues for type importing code in __Pyx_GetVtable()
parent
2acc8dee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-8
No files found.
Cython/Compiler/ModuleNode.py
View file @
4ebbe013
...
...
@@ -2051,12 +2051,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
error_goto_if_null
(
type
.
typeptr_cname
,
pos
))
self
.
use_type_import_utility_code
(
env
)
if
type
.
vtabptr_cname
:
code
.
putln
(
"if (__Pyx_GetVtable(%s->tp_dict, &%s) < 0) %s"
%
(
type
.
typeptr_cname
,
type
.
vtabptr_cname
,
code
.
error_goto
(
pos
)))
env
.
use_utility_code
(
Nodes
.
get_vtable_utility_code
)
code
.
putln
(
"%s = (struct %s*)__Pyx_GetVtable(%s->tp_dict); %s"
%
(
type
.
vtabptr_cname
,
type
.
vtabstruct_cname
,
type
.
typeptr_cname
,
code
.
error_goto_if_null
(
type
.
vtabptr_cname
,
pos
)))
env
.
types_imported
[
type
]
=
1
py3_type_name_map
=
{
'str'
:
'bytes'
,
'unicode'
:
'str'
}
...
...
Cython/Compiler/Nodes.py
View file @
4ebbe013
...
...
@@ -6244,25 +6244,26 @@ bad:
get_vtable_utility_code
=
UtilityCode
(
proto
=
"""
static
int __Pyx_GetVtable(PyObject *dict, void *vtabptr
); /*proto*/
static
void* __Pyx_GetVtable(PyObject *dict
); /*proto*/
"""
,
impl
=
r"""
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
static void* __Pyx_GetVtable(PyObject *dict) {
void* ptr;
PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
if (!ob)
goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
*(void **)vtab
ptr = PyCapsule_GetPointer(ob, 0);
ptr = PyCapsule_GetPointer(ob, 0);
#else
*(void **)vtab
ptr = PyCObject_AsVoidPtr(ob);
ptr = PyCObject_AsVoidPtr(ob);
#endif
if (!
*(void **)vtabptr
)
goto bad
;
if (!
ptr && !PyErr_Occurred()
)
PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type")
;
Py_DECREF(ob);
return
0
;
return
ptr
;
bad:
Py_XDECREF(ob);
return
-1
;
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