Skip to content
This repository was archived by the owner on Jan 3, 2018. It is now read-only.

Crash during QR-Code generation #7

Open
mdornseif opened this issue Jan 26, 2011 · 5 comments
Open

Crash during QR-Code generation #7

mdornseif opened this issue Jan 26, 2011 · 5 comments

Comments

@mdornseif
Copy link
Member

hongshan liu writes:

hi,Maximillian Dornseif,
I was using your huBarcode,but I found some bugs when I using it.

bug example1:
# -- coding: utf-8 --
# author: liu hongshan email: hongshan.liu@...
from hubarcode.qrcode import QRCodeEncoder
if name == "main":
test = "12345"
ENCODER = QRCodeEncoder(test)
ENCODER.save( "test.png",3)

bug info:
File "/home/works/hudora-huBarcode-7a9d83e/hubarcode/qrcode/textencoder.py", line 207, in create_matrix
matrix_content = self.minfo.create_matrix(self.version, self.codewords)
File "/home/works/hudora-huBarcode-7a9d83e/hubarcode/qrcode/isodata.py", line 109, in create_matrix
codeword_i = codewords[i]
IndexError: list index out of range

could you fix these? thank you!

@pbgc
Copy link

pbgc commented Apr 1, 2011

I have the same problem with:

from huBarcode.qrcode import QRCodeEncoder

qr_encoder = QRCodeEncoder(id.zfill(12))
return HttpResponse(content=qr_encoder.get_imagedata(cellsize = 5), mimetype="image/png")

for example with id = 832

@mdornseif
Copy link
Member Author

Does anybody have a patch for this?

@pbgc
Copy link

pbgc commented Jan 16, 2012

Don't have a patch... but a workaround...thats works...:

from huBarcode.qrcode import QRCodeEncoder

qr_encoder = None

try:
    qr_encoder = QRCodeEncoder(id, "M")
except IndexError:
    try:
        qr_encoder = QRCodeEncoder(id, "L")
    except IndexError:
        try:
            qr_encoder = QRCodeEncoder(id, "H")
        except IndexError:
            qr_encoder = QRCodeEncoder(id, "Q")

return HttpResponse(content=qr_encoder.get_imagedata(cellsize = 5), mimetype="image/png")

@rm-hull
Copy link

rm-hull commented Apr 16, 2014

I encountered this today on the 1.0.0 tar.gz from pypi, and fixed it locally - was going to submit a PR, but it looks to have been fixed in commit 205bb1d ... is there any chance 1.0.1 call be pushed up to the cheeseshop?

@ah450
Copy link

ah450 commented Apr 20, 2016

+1 for pushing 1.0.1

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

No branches or pull requests

4 participants