From ac6ef8fe318345f7904050ca56278b55ade7286c Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Fri, 5 Oct 2018 00:23:09 +0000 Subject: [PATCH] Tweaked some miscellaneous code. --- java/io/nayuki/qrcodegen/QrSegment.java | 2 +- python/qrcodegen.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/java/io/nayuki/qrcodegen/QrSegment.java b/java/io/nayuki/qrcodegen/QrSegment.java index b9409b9..b662ca7 100644 --- a/java/io/nayuki/qrcodegen/QrSegment.java +++ b/java/io/nayuki/qrcodegen/QrSegment.java @@ -144,7 +144,7 @@ public final class QrSegment { else if (assignVal < (1 << 14)) { bb.appendBits(2, 2); bb.appendBits(assignVal, 14); - } else if (assignVal < 1000000) { + } else if (assignVal < 1_000_000) { bb.appendBits(6, 3); bb.appendBits(assignVal, 21); } else diff --git a/python/qrcodegen.py b/python/qrcodegen.py index bfa9369..730cd1e 100644 --- a/python/qrcodegen.py +++ b/python/qrcodegen.py @@ -681,7 +681,9 @@ class QrSegment(object): """Creates a new QR Code segment with the given parameters and data. The character count (numch) must agree with the mode and the bit buffer length, but the constraint isn't checked. The given bit buffer is cloned and stored.""" - if numch < 0 or not isinstance(mode, QrSegment.Mode): + if not isinstance(mode, QrSegment.Mode): + raise TypeError("QrSegment.Mode expected") + if numch < 0: raise ValueError() self._mode = mode