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
Xavier Thompson
cython
Commits
50a0470d
Commit
50a0470d
authored
Aug 12, 2011
by
scoder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #38 from vitek/_bindings
CyFunction
parents
508ee78a
80579d55
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
331 additions
and
27 deletions
+331
-27
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+261
-23
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-2
runtests.py
runtests.py
+3
-0
tests/run/cyfunction.pyx
tests/run/cyfunction.pyx
+63
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
50a0470d
This diff is collapsed.
Click to expand it.
Cython/Compiler/ModuleNode.py
View file @
50a0470d
...
...
@@ -1869,8 +1869,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"%s = PyTuple_New(0); %s"
%
(
Naming
.
empty_tuple
,
code
.
error_goto_if_null
(
Naming
.
empty_tuple
,
self
.
pos
)));
code
.
putln
(
"%s = PyBytes_FromStringAndSize(
\
"
\
"
, 0); %s"
%
(
Naming
.
empty_bytes
,
code
.
error_goto_if_null
(
Naming
.
empty_bytes
,
self
.
pos
)));
code
.
putln
(
"#ifdef
%s_USED"
%
Naming
.
binding_cfunc
)
code
.
putln
(
"if (
%s_init() < 0) %s"
%
(
Naming
.
binding_cfunc
,
code
.
error_goto
(
self
.
pos
)
))
code
.
putln
(
"#ifdef
__Pyx_CyFunction_USED"
)
code
.
putln
(
"if (
__Pyx_CyFunction_init() < 0) %s"
%
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"#endif"
)
code
.
putln
(
"/*--- Library function declarations ---*/"
)
...
...
Cython/Compiler/Symtab.py
View file @
50a0470d
...
...
@@ -2047,8 +2047,8 @@ static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
else if (PyCFunction_Check(method)) {
return PyClassMethod_New(method);
}
#ifdef __
pyx_binding_PyCFunctionType
_USED
else if (PyObject_TypeCheck(method, __pyx_
binding_PyCFunctionType)) { /* binded CFunction */
#ifdef __
Pyx_CyFunction
_USED
else if (PyObject_TypeCheck(method, __pyx_
CyFunctionType)) {
return PyClassMethod_New(method);
}
#endif
...
...
runtests.py
View file @
50a0470d
...
...
@@ -433,6 +433,7 @@ class CythonCompileTestCase(unittest.TestCase):
from Cython.Compiler import Options
self._saved_options = [ (name, getattr(Options, name))
for name in ('warning_errors', 'error_on_unknown_names') ]
self._saved_default_directives = Options.directive_defaults.items()
Options.warning_errors = self.warning_errors
if self.workdir not in sys.path:
...
...
@@ -442,6 +443,7 @@ class CythonCompileTestCase(unittest.TestCase):
from Cython.Compiler import Options
for name, value in self._saved_options:
setattr(Options, name, value)
Options.directive_defaults = dict(self._saved_default_directives)
try:
sys.path.remove(self.workdir)
...
...
@@ -849,6 +851,7 @@ class CythonPyregrTestCase(CythonRunTestCase):
CythonRunTestCase.setUp(self)
from Cython.Compiler import Options
Options.error_on_unknown_names = False
Options.directive_defaults['binding'] = True
def _run_unittest(self, result, *classes):
"""Run tests from unittest.TestCase-derived classes."""
...
...
tests/run/cyfunction.pyx
0 → 100644
View file @
50a0470d
# cython: binding=True
# mode: run
# tag: cyfunction
def
test_dict
():
"""
>>> test_dict.foo = 123
>>> test_dict.__dict__
{'foo': 123}
>>> test_dict.__dict__ = {'bar': 321}
>>> test_dict.__dict__
{'bar': 321}
>>> test_dict.func_dict
{'bar': 321}
"""
def
test_name
():
"""
>>> test_name.__name__
'test_name'
>>> test_name.func_name
'test_name'
>>> test_name.__name__ = 123 #doctest:+ELLIPSIS
Traceback (most recent call last):
TypeError: __name__ must be set to a ... object
>>> test_name.__name__ = 'foo'
>>> test_name.__name__
'foo'
"""
def
test_doc
():
"""
>>> del test_doc.__doc__
>>> test_doc.__doc__
>>> test_doc.__doc__ = 'docstring'
>>> test_doc.__doc__
'docstring'
>>> test_doc.func_doc
'docstring'
"""
def
test_reduce
():
"""
>>> import pickle
>>> pickle.loads(pickle.dumps(test_reduce))()
'Hello, world!'
"""
return
'Hello, world!'
def
test_method
(
self
):
return
self
class
BindingTest
:
"""
>>> BindingTest.test_method = test_method
>>> BindingTest.test_method() #doctest:+ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> BindingTest().test_method()
<BindingTest instance>
"""
def
__repr__
(
self
):
return
'<BindingTest instance>'
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