8000 Using qr with a large (9599 byte) text file raises a ValueError exception · Issue #396 · lincolnloop/python-qrcode · GitHub
[go: up one dir, main page]

Skip to content
Using qr with a large (9599 byte) text file raises a ValueError exception #396
@jeffsilverm

Description

@jeffsilverm

If I feed a moderately large (9599 byte) text file into qr, it raises a ValueError exception:

(venv) jeffs@frmwrk16:~/software/python$ qr < /home/jeffs/Downloads/Python-3.10.0/Lib/idlelib/README.txt > idlelib_README.png
Traceback (most recent call last):
  File "/home/jeffs/software/python/venv/bin/qr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/console_scripts.py", line 138, in main
    img = qr.make_image(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/main.py", line 353, in make_image
    self.make()
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/main.py", line 156, in make
    self.best_fit(start=self.version)
                        ^^^^^^^^^^^^
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/main.py", line 104, in version
    self.best_fit()
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/main.py", line 226, in best_fit
    self.version = bisect_left(
    ^^^^^^^^^^^^
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/main.py", line 111, in version
    util.check_version(value)
  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/util.py", line 184, in check_version
    raise ValueError(f"Invalid version (was {version}, expected 1 to 40)")
ValueError: Invalid version (was 41, expected 1 to 40)
(venv) jeffs@frmwrk16:~/software/python$ 

I changed 40 to 41 in util.py line 183 and that change got past the check but then another exception was raised:

  File "/home/jeffs/software/python/venv/lib/python3.12/site-packages/qrcode/main.py", line 230, in best_fit
    raise exceptions.DataOverflowError()
qrcode.exceptions.DataOverflowError

At that point, I realized that the problem is non-trivial, so I defer to the maintainers.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0