Whole file

heuer/segno

The author described this change as CLI raises no exception with a traceback anymore but writes the error msg to std.error and returns an error code.. It counts as a record because the check below fails on the code as it stood at 79307d856 and passes on 01bd15d31, with nothing else changed between the two runs.

Fix saved2018-03-18
Sharing licenceBSD-3-Clause · LICENSE
Change size+7 1

What the code was meant to do, written into the code itself as a save note

CLI raises no exception with a traceback anymore but writes the error msg to std.error and returns an error code.

The change

1212 "QR Code" and "Micro QR Code" are registered trademarks of DENSO WAVE INCORPORATED.
1313 """
1414 from __future__ import absolute_import, unicode_literals
15+import os
1516 import sys
1617 import argparse
1718 import segno
192193
193194 def main(args=sys.argv[1:]):
194195 config = parse(args)
195- qr = make_code(config)
196+ try:
197+ qr = make_code(config)
198+ except segno.QRCodeError as ex:
199+ sys.stderr.writelines([str(ex), os.linesep])
200+ return sys.exit(1)
196201 output = config.pop('output')
197202 if output is None:
198203 qr.terminal(border=config['border'])
199204 else:
200205 qr.save(output, **build_config(config, filename=output))
206+ return 0
201207
202208
203209 class _AttrDict(dict):

The check that tells the two apart

failpass·tests/test_cli.py::test_error_code

Check file tests/test_cli.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it79307d85681bcccff1102cd2f3a1ae1b2364b29d
Broken version dated2018-02-25
Modulesegno.cli
Units changedmain
Fingerprintecaf07999dd091de
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in heuer/segno