Commit ec95e0e1 authored by Stefan Behnel's avatar Stefan Behnel

Add working test case from #1606.

Closes #1606.
parent ea0359d9
# mode: run
# tag: pickle
PYTHON main.py build_ext -i
######################### lib/__init__.py #########################
######################### lib/cy.pyx #########################
# cython: binding=True
cdef class WithoutC:
def hello(self):
return "Hello, World"
cdef class WithCPDef:
cpdef str hello(self):
return "Hello, World"
cdef class WithCDefWrapper:
def hello(self):
return _helloC(self)
cpdef _helloC(object caller):
return "Hello, World"
######################### lib/cy.pxd #########################
# cython:language_level=3
cdef class WithoutCPDef:
pass
cdef class WithCPDef:
cpdef str hello(self)
cdef class WithCDefWrapper:
pass
cpdef _helloC(object caller)
######################### main.py #########################
#!/usr/bin/env python3
from Cython.Build import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize(["lib/*.pyx"]),
)
import pickle as pkl
import os
from lib.cy import WithoutC, WithCPDef, WithCDefWrapper
def tryThis(obj):
print("Pickling %s ..." % obj.__class__.__name__)
try:
pkl.dump(obj, open("test.pkl", "wb"))
print("\t... OK")
except Exception as e:
print("\t... KO: %s" % str(e))
try:
for t in WithoutC(), WithCPDef(), WithCDefWrapper():
tryThis(t)
finally:
if os.path.exists("test.pkl"):
os.remove("test.pkl")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment