Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cythonise fails Cannot convert 'string' to Python object #25

Closed
nhandtvt opened this issue Nov 13, 2013 · 3 comments
Closed

Cythonise fails Cannot convert 'string' to Python object #25

nhandtvt opened this issue Nov 13, 2013 · 3 comments
Labels

Comments

@nhandtvt
Copy link

Hi,
I've installed PyQL. I followed every steps in https://github.com/enthought/pyql/blob/master/docs/source/getting_started.rst
But when compiling pyql, I got the issue:

Cythonizing quantlib/interest_rate.pyx

Error compiling Cython file:
------------------------------------------------------------
...
                cpd_str = "simple compounding up to {0} months," \
                              "then  {1} compounding".format(12/self.frequency, freq_str)
        else:
            ValueError('unknown compounding convention ({0})'.format(self.compounding))
        return "{0:.2f} {1} {2}".format(
            self.rate, self._thisptr.get().dayCounter().name(), cpd_str
                                                           ^
------------------------------------------------------------

quantlib/interest_rate.pyx:104:60: Cannot convert 'string' to Python object
Traceback (most recent call last):
  File "setup.py", line 224, in <module>
    ext_modules = collect_extensions(),
  File "setup.py", line 203, in collect_extensions
    ) for dirpath in cython_extension_directories
  File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 543, in cythonize
    cythonize_one(pyx_file, c_file, quiet, options)
  File "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line 566, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: quantlib/interest_rate.pyx

Help me please.
Many thanks

@dpinte
Copy link
Member

dpinte commented Nov 13, 2013

@nhandtvt What version of Cython do you have?

@nhandtvt
Copy link
Author

Hi,
I used Cython 0.16. I fixed that issue by adding c_str() in the last line of quantlib/interest_rate.pyx

return "{0:.2f} {1} {2}".format(
        self.rate, self._thisptr.get().dayCounter().name().c_str(), cpd_str
    )

Thanks.

@dpinte
Copy link
Member

dpinte commented Nov 14, 2013

@nhandtvt Great. It works fine on 0.19. Closing as fixed.

@dpinte dpinte closed this as completed Nov 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants