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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a152462e
Commit
a152462e
authored
Feb 15, 2018
by
Jeroen Demeyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In Python 3, an unbound method is just the function
parent
969dbad1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+1
-1
tests/run/cyfunction.pyx
tests/run/cyfunction.pyx
+19
-0
tests/run/pure_py.py
tests/run/pure_py.py
+12
-0
No files found.
Cython/Utility/ModuleSetupCode.c
View file @
a152462e
...
@@ -617,7 +617,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
...
@@ -617,7 +617,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#endif
#endif
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) :
PyInstanceMethod_New(
func))
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) :
(Py_INCREF(func),
func))
#else
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#endif
...
...
tests/run/cyfunction.pyx
View file @
a152462e
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
# tag: cyfunction
# tag: cyfunction
import
sys
import
sys
IS_PY2
=
sys
.
version_info
[
0
]
<
3
IS_PY3
=
sys
.
version_info
[
0
]
>=
3
IS_PY3
=
sys
.
version_info
[
0
]
>=
3
IS_PY34
=
sys
.
version_info
>
(
3
,
4
,
0
,
'beta'
,
3
)
IS_PY34
=
sys
.
version_info
>
(
3
,
4
,
0
,
'beta'
,
3
)
...
@@ -348,3 +349,21 @@ cdef class TestDecoratedMethods:
...
@@ -348,3 +349,21 @@ cdef class TestDecoratedMethods:
2
2
"""
"""
return
x
return
x
cdef
class
TestUnboundMethodCdef
:
"""
>>> C = TestUnboundMethodCdef
>>> IS_PY2 or (C.meth is C.__dict__["meth"])
True
"""
def
meth
(
self
):
pass
class
TestUnboundMethod
:
"""
>>> C = TestUnboundMethod
>>> IS_PY2 or (C.meth is C.__dict__["meth"])
True
"""
def
meth
(
self
):
pass
tests/run/pure_py.py
View file @
a152462e
import
sys
IS_PY2
=
sys
.
version_info
[
0
]
<
3
import
cython
import
cython
is_compiled
=
cython
.
compiled
is_compiled
=
cython
.
compiled
...
@@ -360,3 +363,12 @@ class CClass(object):
...
@@ -360,3 +363,12 @@ class CClass(object):
def
get_attr
(
self
):
def
get_attr
(
self
):
print
(
cython
.
typeof
(
self
.
attr
))
print
(
cython
.
typeof
(
self
.
attr
))
return
self
.
attr
return
self
.
attr
class
TestUnboundMethod
:
"""
>>> C = TestUnboundMethod
>>> IS_PY2 or (C.meth is C.__dict__["meth"])
True
"""
def
meth
(
self
):
pass
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