jmptbl / python-zint

Python ctypes interface to libzint
BSD 3-Clause "New" or "Revised" License
6 stars 7 forks source link

Pointer exceptions with zint version 2.6.3 #4

Closed msharp closed 5 years ago

msharp commented 5 years ago

When using Zint version 2.6.3, calls to zint.bitmapbuf() throw a ValueError.

Like this:

Traceback (most recent call last):
  File "/app/.local/share/virtualenvs/src-sjxfABcx/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 135, in handle
    self.handle_request(listener, req, client, addr)
  File "/app/.local/share/virtualenvs/src-sjxfABcx/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/app/.local/share/virtualenvs/src-sjxfABcx/lib/python3.7/site-packages/falcon/api.py", line 269, in __call__
    responder(req, resp, **params)
  File "/app/src/barcodez.py", line 193, in on_get
    resp.stream = bc.barcode()
  File "/app/src/barcodez.py", line 74, in barcode
    img = self._get_png_image()
  File "/app/src/barcodez.py", line 124, in _get_png_image
    frame = self._get_pixel_map()
  File "/app/src/barcodez.py", line 101, in _get_pixel_map
    bitmap = zint.bitmapbuf(self.symbol)
  File "/app/.local/share/virtualenvs/src-sjxfABcx/src/zint/zint/zint.py", line 192, in bitmapbuf
    return cast(z.contents.bitmap, POINTER(c_char * blen))[0]
ValueError: NULL pointer access

Or this:

Traceback (most recent call last):
  File "/app/.local/share/virtualenvs/src-sjxfABcx/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 135, in handle
    self.handle_request(listener, req, client, addr)
  File "/app/.local/share/virtualenvs/src-sjxfABcx/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/app/.local/share/virtualenvs/src-sjxfABcx/lib/python3.7/site-packages/falcon/api.py", line 269, in __call__
    responder(req, resp, **params)
  File "/app/src/barcodez.py", line 192, in on_get
    resp.stream = bc.barcode()
  File "/app/src/barcodez.py", line 74, in barcode
    img = self._get_png_image()
  File "/app/src/barcodez.py", line 124, in _get_png_image
    frame = self._get_pixel_map()
  File "/app/src/barcodez.py", line 101, in _get_pixel_map
    bitmap = zint.bitmapbuf(self.symbol)
  File "/app/.local/share/virtualenvs/src-sjxfABcx/src/zint/zint/zint.py", line 192, in bitmapbuf
    return cast(z.contents.bitmap, POINTER(c_char * blen))[0]
ValueError: Array length must be >= 0, not -38358258164736

The problem seems to be that Zint introduced a new symbol property for fontsize in this commit and it is incompatible with the python code.

jmptbl commented 5 years ago

Fixed, and recently released as v1.2. Published to PyPi as well. Thank you for your input!