lincolnloop / python-qrcode

Python QR Code image generator
https://pypi.python.org/pypi/qrcode
Other
4.25k stars 660 forks source link

Data overflow fixes #323

Open guusbertens opened 1 year ago

guusbertens commented 1 year ago

Correctly raise DataOverflowError and display a nicer message on the command line. Comments are welcome!

Fixes issues #273 and #322.

guusbertens commented 1 year ago

One of my commits replaces self.version with self._version. While this is not strictly necessary, it makes it so that QRCode.make() calls best_fit by itself, without relying on the getter QRCode.version. The call to best_fit in the getter fn ensures the call to best_fit in make will never be used, which seems unintended. This also makes any exceptions thrown come from a more logical place.

@SmileyChris, what do you think? Should the getter fn modify QRCode's state, even though it's a getter function? I'm mostly curious, but if needed can update this PR.