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
Kirill Smelkov
cython
Commits
34bc649f
Commit
34bc649f
authored
Oct 02, 2018
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use enum rather than int for size_check.
parent
fbd2fd09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
14 deletions
+17
-14
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-9
Cython/Utility/ImportExport.c
Cython/Utility/ImportExport.c
+12
-5
No files found.
Cython/Compiler/ModuleNode.py
View file @
34bc649f
...
...
@@ -3060,18 +3060,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
put
(
'sizeof(%s), '
%
objstruct
)
# check_size
if
not
type
.
is_external
or
type
.
is_subclassed
:
cs
=
0
elif
type
.
check_size
==
'error'
:
cs
=
0
elif
type
.
check_size
==
'warn'
:
cs
=
1
elif
type
.
check_size
==
'ignore'
:
cs
=
2
if
type
.
check_size
and
type
.
check_size
in
(
'error'
,
'warn'
,
'ignore'
):
check_size
=
type
.
check_size
elif
not
type
.
is_external
or
type
.
is_subclassed
:
check_size
=
'error'
else
:
raise
RuntimeError
(
"invalid value for check_size '%s' when compiling %s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
code
.
putln
(
'
%d);'
%
cs
)
code
.
putln
(
'
__Pyx_ImportType_CheckSize_%s);'
%
check_size
.
title
()
)
code
.
putln
(
' if (!%s) %s'
%
(
type
.
typeptr_cname
,
error_code
))
...
...
Cython/Utility/ImportExport.c
View file @
34bc649f
...
...
@@ -309,14 +309,21 @@ set_path:
/////////////// TypeImport.proto ///////////////
static
PyTypeObject
*
__Pyx_ImportType
(
PyObject
*
module
,
const
char
*
module_name
,
const
char
*
class_name
,
size_t
size
,
int
check_size
);
/*proto*/
enum
__Pyx_ImportType_CheckSize
{
__Pyx_ImportType_CheckSize_Error
=
0
,
__Pyx_ImportType_CheckSize_Warn
=
1
,
__Pyx_ImportType_CheckSize_Ignore
=
2
};
static
PyTypeObject
*
__Pyx_ImportType
(
PyObject
*
module
,
const
char
*
module_name
,
const
char
*
class_name
,
size_t
size
,
enum
__Pyx_ImportType_CheckSize
check_size
);
/*proto*/
/////////////// TypeImport ///////////////
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static
PyTypeObject
*
__Pyx_ImportType
(
PyObject
*
module
,
const
char
*
module_name
,
const
char
*
class_name
,
size_t
size
,
int
check_size
)
size_t
size
,
enum
__Pyx_ImportType_CheckSize
check_size
)
{
/*
* 'check_size' tells what to do if tp_basicsize is different from size:
...
...
@@ -359,21 +366,21 @@ static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name,
module_name
,
class_name
,
size
,
basicsize
);
goto
bad
;
}
if
(
check_size
==
0
&&
(
size_t
)
basicsize
!=
size
)
{
if
(
check_size
==
__Pyx_ImportType_CheckSize_Error
&&
(
size_t
)
basicsize
!=
size
)
{
PyErr_Format
(
PyExc_ValueError
,
"%.200s.%.200s size changed, may indicate binary incompatibility. "
"Expected %zd from C header, got %zd from PyObject"
,
module_name
,
class_name
,
size
,
basicsize
);
goto
bad
;
}
else
if
(
check_size
==
1
&&
(
size_t
)
basicsize
>
size
)
{
else
if
(
check_size
==
__Pyx_ImportType_CheckSize_Warn
&&
(
size_t
)
basicsize
>
size
)
{
PyOS_snprintf
(
warning
,
sizeof
(
warning
),
"%s.%s size changed, may indicate binary incompatibility. "
"Expected %zd from C header, got %zd from PyObject"
,
module_name
,
class_name
,
size
,
basicsize
);
if
(
PyErr_WarnEx
(
NULL
,
warning
,
0
)
<
0
)
goto
bad
;
}
/* check_size ==
2
does not warn nor error */
/* check_size ==
__Pyx_ImportType_CheckSize_Ignore
does not warn nor error */
return
(
PyTypeObject
*
)
result
;
bad:
Py_XDECREF
(
result
);
...
...
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