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
920aee84
Commit
920aee84
authored
Sep 25, 2018
by
mattip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MAINT: fixes from review
parent
37fb8a2d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
30 deletions
+27
-30
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+8
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-3
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+1
-1
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+4
-4
runtests.py
runtests.py
+3
-10
tests/run/check_size.srctree
tests/run/check_size.srctree
+3
-3
No files found.
Cython/Compiler/ModuleNode.py
View file @
920aee84
...
...
@@ -3061,15 +3061,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# check_size
if
not
type
.
is_external
or
type
.
is_subclassed
:
if
type
.
check_size
!=
'min'
:
raise
AttributeError
(
"unexpected check_size value '%s' when "
"compiling %s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
cs
=
0
elif
type
.
check_size
==
b
'min'
:
elif
type
.
check_size
==
'min'
:
cs
=
1
elif
type
.
check_size
is
True
:
elif
type
.
check_size
==
'True'
:
cs
=
0
elif
type
.
check_size
is
False
:
elif
type
.
check_size
==
'False'
:
cs
=
2
else
:
raise
AttributeError
(
"invalid value for check_size '%
r
' when compiling "
raise
AttributeError
(
"invalid value for check_size '%
s
' when compiling "
"%s.%s"
%
(
type
.
check_size
,
module_name
,
type
.
name
))
code
.
putln
(
'%d);'
%
cs
)
...
...
Cython/Compiler/Nodes.py
View file @
920aee84
...
...
@@ -4629,7 +4629,7 @@ class CClassDefNode(ClassDefNode):
# bases TupleNode Base class(es)
# objstruct_name string or None Specified C name of object struct
# typeobj_name string or None Specified C name of type object
# check_size
b'min' or boolean Issue warning
if tp_basicsize does not match
# check_size
'min' or boolean What to do
if tp_basicsize does not match
# in_pxd boolean Is in a .pxd file
# decorators [DecoratorNode] list of decorators or None
# doc string or None
...
...
@@ -4646,7 +4646,7 @@ class CClassDefNode(ClassDefNode):
api
=
False
objstruct_name
=
None
typeobj_name
=
None
check_size
=
b
'min'
check_size
=
'min'
decorators
=
None
shadow
=
False
...
...
Cython/Compiler/Parsing.py
View file @
920aee84
...
...
@@ -3471,7 +3471,7 @@ def p_c_class_definition(s, pos, ctx):
objstruct_name
=
None
typeobj_name
=
None
bases
=
None
check_size
=
b
'min'
check_size
=
'min'
if
s
.
sy
==
'('
:
positional_args
,
keyword_args
=
p_call_parse_args
(
s
,
allow_genexp
=
False
)
if
keyword_args
:
...
...
@@ -3530,7 +3530,7 @@ def p_c_class_definition(s, pos, ctx):
def
p_c_class_options
(
s
):
objstruct_name
=
None
typeobj_name
=
None
check_size
=
b
'min'
check_size
=
'min'
s
.
expect
(
'['
)
while
1
:
if
s
.
sy
!=
'IDENT'
:
...
...
@@ -3543,7 +3543,7 @@ def p_c_class_options(s):
typeobj_name
=
p_ident
(
s
)
elif
s
.
systring
==
'check_size'
:
s
.
next
()
check_size
=
p_
atom
(
s
).
value
check_size
=
p_
ident
(
s
)
if
s
.
sy
!=
','
:
break
s
.
next
()
...
...
Cython/Compiler/PyrexTypes.py
View file @
920aee84
...
...
@@ -1345,14 +1345,15 @@ class PyExtensionType(PyObjectType):
# vtable_cname string Name of C method table definition
# early_init boolean Whether to initialize early (as opposed to during module execution).
# defered_declarations [thunk] Used to declare class hierarchies in order
# check_size
b'min' or boolean should tp_basicsize match sizeof(obstruct_cname)
# check_size
'min' or boolean What to do if tp_basicsize does not match
is_extension_type
=
1
has_attributes
=
1
early_init
=
1
objtypedef_cname
=
None
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
,
is_external
=
0
,
check_size
=
b'min'
):
def
__init__
(
self
,
name
,
typedef_flag
,
base_type
,
is_external
=
0
,
check_size
=
'min'
):
self
.
name
=
name
self
.
scope
=
None
self
.
typedef_flag
=
typedef_flag
...
...
Cython/Compiler/Symtab.py
View file @
920aee84
...
...
@@ -1476,7 +1476,7 @@ class ModuleScope(Scope):
def
declare_c_class
(
self
,
name
,
pos
,
defining
=
0
,
implementing
=
0
,
module_name
=
None
,
base_type
=
None
,
objstruct_cname
=
None
,
typeobj_cname
=
None
,
typeptr_cname
=
None
,
visibility
=
'private'
,
typedef_flag
=
0
,
api
=
0
,
check_size
=
b
'min'
,
typedef_flag
=
0
,
api
=
0
,
check_size
=
'min'
,
buffer_defaults
=
None
,
shadow
=
0
):
# If this is a non-extern typedef class, expose the typedef, but use
# the non-typedef struct internally to avoid needing forward
...
...
docs/src/userguide/extension_types.rst
View file @
920aee84
...
...
@@ -736,11 +736,11 @@ built-in complex object.::
...
} PyComplexObject;
At runtime, a check will be performed when importing the
c
ython
At runtime, a check will be performed when importing the
C
ython
c-extension module that ``__builtin__.complex``'s ``tp_basicsize``
matches ``sizeof(`PyComplexObject)``. This check can fail if
in the c
ython
matches ``sizeof(`PyComplexObject)``. This check can fail if
the C
ython
c-extension module was compiled with one version of the
``complexobject.h`` header but imported into a
p
ython with a changed
``complexobject.h`` header but imported into a
P
ython with a changed
header. This check can be tweaked by using ``check_size`` in the name
specification clause.
...
...
@@ -771,7 +771,7 @@ Where:
- ``object_struct_name`` is the name to assume for the type's C struct.
- ``type_object_name`` is the name to assume for the type's statically
declared type object.
- ``cs_option`` is ``
'min'
`` (the default), ``True``, or ``False`` and is only
- ``cs_option`` is ``
min
`` (the default), ``True``, or ``False`` and is only
used for external extension types. If ``True``, ``sizeof(object_struct)`` must
match the type's ``tp_basicsize``. If ``False``, or ``min``, the
``object_struct`` may be smaller than the type's ``tp_basicsize``, which
...
...
runtests.py
View file @
920aee84
...
...
@@ -1735,9 +1735,6 @@ class EndToEndTest(unittest.TestCase):
old_path = os.environ.get('PYTHONPATH')
env = dict(os.environ)
env['PYTHONPATH'] = self.cython_syspath + os.pathsep + (old_path or '')
cmd = []
out = []
err = []
for command_no, command in enumerate(filter(None, commands.splitlines()), 1):
with self.stats.time('%s(%d)' % (self.name, command_no), 'c',
'etoe-build' if ' setup.py ' in command else 'etoe-run'):
...
...
@@ -1746,15 +1743,11 @@ class EndToEndTest(unittest.TestCase):
stdout=subprocess.PIPE,
shell=True,
env=env)
_out, _err = p.communicate()
cmd.append(command)
out.append(_out)
err.append(_err)
out, err = p.communicate()
res = p.returncode
if res != 0:
for c, o, e in zip(cmd, out, err):
sys.stderr.write("%s
\
n
%s
\
n
%s
\
n
\
n
" % (
c, self._try_decode(o), self._try_decode(e)))
sys.stderr.write("%s
\
n
%s
\
n
%s
\
n
" % (
command, self._try_decode(out), self._try_decode(err)))
self.assertEqual(0, res, "non-zero exit status")
self.success = True
...
...
tests/run/check_size.srctree
View file @
920aee84
...
...
@@ -129,8 +129,8 @@ cpdef public int testme(Foo f) except -1:
cdef extern from "check_size_smaller.h":
# make sure missing check_size is equivalent to
'min'
ctypedef class check_size.Foo [object FooStructSmall, check_size
'min'
]:
# make sure missing check_size is equivalent to
min
ctypedef class check_size.Foo [object FooStructSmall, check_size
min
]:
cdef:
int f9
...
...
@@ -169,7 +169,7 @@ cpdef public int testme(Foo f) except -1:
cdef extern from "check_size_smaller.h":
# Raise AttributeError when using bad value
ctypedef class check_size.Foo [object FooStructSmall, check_size
'max'
]:
ctypedef class check_size.Foo [object FooStructSmall, check_size
max
]:
cdef:
int f9
...
...
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