lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.9-14-g6b85f91

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.9-14-g6b85f91



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  6b85f91f64c38f7c1641d2a7e3019c27f5329800 (commit)
      from  58ea7b20682021e9ed91587adb484534fb7a768f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=6b85f91f64c38f7c1641d2a7e3019c27f5329800

commit 6b85f91f64c38f7c1641d2a7e3019c27f5329800
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Oct 14 19:16:55 2018 +0200

    Raise InvalidComponent on unknown IBAN country
    
    This partially reverts 58ea7b2.
    
    Closes https://github.com/arthurdejong/python-stdnum/issues/82

diff --git a/stdnum/iban.py b/stdnum/iban.py
index bbf181b..bdd0799 100644
--- a/stdnum/iban.py
+++ b/stdnum/iban.py
@@ -104,9 +104,11 @@ def validate(number, check_country=True):
     mod_97_10.validate(number[4:] + number[:4])
     # look up the number
     info = _ibandb.info(number)
+    if not info[0][1]:
+        raise InvalidComponent()
     # check if the bban part of number has the correct structure
     bban = number[4:]
-    if not _struct_to_re(info[0][1].get('bban', '-')).match(bban):
+    if not _struct_to_re(info[0][1].get('bban', '')).match(bban):
         raise InvalidFormat()
     # check the country-specific module if it exists
     if check_country:
diff --git a/tests/test_iban.doctest b/tests/test_iban.doctest
index 0625fb1..083ce88 100644
--- a/tests/test_iban.doctest
+++ b/tests/test_iban.doctest
@@ -31,7 +31,15 @@ country code is unknown and the checksum is still valid.
 >>> iban.validate('0001')
 Traceback (most recent call last):
     ...
-InvalidFormat: ...
+InvalidComponent: ...
+
+
+IBAN for an unknown country code.
+
+>>> iban.validate('XX431234')
+Traceback (most recent call last):
+    ...
+InvalidComponent: ...
 
 
 These should all be valid numbers and are from the IBAN REGISTRY as sample

-----------------------------------------------------------------------

Summary of changes:
 stdnum/iban.py          |  4 +++-
 tests/test_iban.doctest | 10 +++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
python-stdnum
-- 
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-stdnum-commits/