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
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
Show 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):
...
@@ -3060,18 +3060,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
put
(
'sizeof(%s), '
%
objstruct
)
code
.
put
(
'sizeof(%s), '
%
objstruct
)
# check_size
# check_size
if
not
type
.
is_external
or
type
.
is_subclassed
:
if
type
.
check_size
and
type
.
check_size
in
(
'error'
,
'warn'
,
'ignore'
):
cs
=
0
check_size
=
type
.
check_size
elif
type
.
check_size
==
'error'
:
elif
not
type
.
is_external
or
type
.
is_subclassed
:
cs
=
0
check_size
=
'error'
elif
type
.
check_size
==
'warn'
:
cs
=
1
elif
type
.
check_size
==
'ignore'
:
cs
=
2
else
:
else
:
raise
RuntimeError
(
"invalid value for check_size '%s' when compiling %s.%s"
%
(
raise
RuntimeError
(
"invalid value for check_size '%s' when compiling %s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
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
))
code
.
putln
(
' if (!%s) %s'
%
(
type
.
typeptr_cname
,
error_code
))
...
...
Cython/Utility/ImportExport.c
View file @
34bc649f
...
@@ -309,14 +309,21 @@ set_path:
...
@@ -309,14 +309,21 @@ set_path:
/////////////// TypeImport.proto ///////////////
/////////////// 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 ///////////////
/////////////// TypeImport ///////////////
#ifndef __PYX_HAVE_RT_ImportType
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static
PyTypeObject
*
__Pyx_ImportType
(
PyObject
*
module
,
const
char
*
module_name
,
const
char
*
class_name
,
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:
* '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,
...
@@ -359,21 +366,21 @@ static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name,
module_name
,
class_name
,
size
,
basicsize
);
module_name
,
class_name
,
size
,
basicsize
);
goto
bad
;
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
,
PyErr_Format
(
PyExc_ValueError
,
"%.200s.%.200s size changed, may indicate binary incompatibility. "
"%.200s.%.200s size changed, may indicate binary incompatibility. "
"Expected %zd from C header, got %zd from PyObject"
,
"Expected %zd from C header, got %zd from PyObject"
,
module_name
,
class_name
,
size
,
basicsize
);
module_name
,
class_name
,
size
,
basicsize
);
goto
bad
;
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
),
PyOS_snprintf
(
warning
,
sizeof
(
warning
),
"%s.%s size changed, may indicate binary incompatibility. "
"%s.%s size changed, may indicate binary incompatibility. "
"Expected %zd from C header, got %zd from PyObject"
,
"Expected %zd from C header, got %zd from PyObject"
,
module_name
,
class_name
,
size
,
basicsize
);
module_name
,
class_name
,
size
,
basicsize
);
if
(
PyErr_WarnEx
(
NULL
,
warning
,
0
)
<
0
)
goto
bad
;
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
;
return
(
PyTypeObject
*
)
result
;
bad:
bad:
Py_XDECREF
(
result
);
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