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

SystemError: <built-in method callback_decorator ...> returned NULL without setting an error #105

Closed
codingcatgirl opened this issue Oct 17, 2017 · 1 comment

Comments

@codingcatgirl
Copy link

codingcatgirl commented Oct 17, 2017

This following exception happens on gentoo when calling surface.write_to_png() after using rsvg to render an svg.

  • python 3.6
  • cairo 1.14.8
  • cairocffi 0.8.0, installed from pip

the code works on other operating systems (tested on arch), so i guess it's some dependency problem. what could it be?

Traceback (most recent call last):
  […]
  File "/opt/c3nav/instances/34c3/c3nav/src/c3nav/mapdata/utils/svg.py", line 92, in get_png
    f.write(surface.write_to_png())
  File "/opt/c3nav/instances/34c3/env/lib/python3.6/site-packages/cairocffi/surfaces.py", line 593, in write_to_png
    write_func = _make_write_func(target)
  File "/opt/c3nav/instances/34c3/env/lib/python3.6/site-packages/cairocffi/surfaces.py", line 42, in _make_write_func
    @ffi.callback("cairo_write_func_t", error=constants.STATUS_WRITE_ERROR)
SystemError: <built-in method callback_decorator of tuple object at 0x676b04d14d18> returned NULL without setting an error

the exception can be triggered easily in a python shell:

>>> import cairocffi
>>> surface = cairocffi.SVGSurface(None, 10, 10)
>>> print(surface.write_to_png())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/c3nav/instances/34c3/env/lib/python3.6/site-packages/cairocffi/surfaces.py", line 593, in write_to_png
    write_func = _make_write_func(target)
  File "/opt/c3nav/instances/34c3/env/lib/python3.6/site-packages/cairocffi/surfaces.py", line 42, in _make_write_func
    @ffi.callback("cairo_write_func_t", error=constants.STATUS_WRITE_ERROR)
SystemError: <built-in method callback_decorator of tuple object at 0x752d9f20fc78> returned NULL without setting an error
>>> surface = cairocffi.SVGSurface(None, 10, 10)
@codingcatgirl
Copy link
Author

I found the source. The Problem is that your code uses old-style callbacks, which do not work on hardened systems. The solution would be to convert your callbacks to new-style callbacks. I would offer a pull request, but as cairocffi uses cffi in ABI mode, it is not possible to use them. So i guess i'll have to un-harden the server i want to run it on or look for other cairo bindings. 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant