From dec01bcdab513f5842469732c0c997e0fedb5c0d Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Mon, 7 Sep 2015 22:08:56 -0400 Subject: [PATCH] more error checking - see issue #57 --- py25/bacpypes/primitivedata.py | 6 +++--- py27/bacpypes/primitivedata.py | 4 ++-- py34/bacpypes/primitivedata.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/py25/bacpypes/primitivedata.py b/py25/bacpypes/primitivedata.py index 9012e8e..d1c458a 100755 --- a/py25/bacpypes/primitivedata.py +++ b/py25/bacpypes/primitivedata.py @@ -1197,7 +1197,7 @@ class Date(Atomic): month = int(month) if (month == 255): pass - elif month > 14: + elif (month == 0) or (month > 14): raise ValueError("invalid month") # extract the day and normalize @@ -1208,7 +1208,7 @@ class Date(Atomic): day = int(day) if (day == 255): pass - elif day > 34: + elif (day == 0) or (day > 34): raise ValueError("invalid day") # extract the day-of-week and normalize @@ -1221,7 +1221,7 @@ class Date(Atomic): day_of_week = int(day_of_week) if (day_of_week == 255): pass - elif day_of_week > 7: + elif (day_of_week == 0) or (day_of_week > 7): raise ValueError("invalid day of week") # year becomes the correct octet diff --git a/py27/bacpypes/primitivedata.py b/py27/bacpypes/primitivedata.py index 85558ea..7ef4057 100755 --- a/py27/bacpypes/primitivedata.py +++ b/py27/bacpypes/primitivedata.py @@ -1203,7 +1203,7 @@ class Date(Atomic): month = int(month) if (month == 255): pass - elif month > 14: + elif (month == 0) or (month > 14): raise ValueError("invalid month") # extract the day and normalize @@ -1214,7 +1214,7 @@ class Date(Atomic): day = int(day) if (day == 255): pass - elif day > 34: + elif (day == 0) or (day > 34): raise ValueError("invalid day") # extract the day-of-week and normalize diff --git a/py34/bacpypes/primitivedata.py b/py34/bacpypes/primitivedata.py index 7506080..b352ab9 100755 --- a/py34/bacpypes/primitivedata.py +++ b/py34/bacpypes/primitivedata.py @@ -1211,7 +1211,7 @@ class Date(Atomic): month = int(month) if (month == 255): pass - elif month > 14: + elif (month == 0) or (month > 14): raise ValueError("invalid month") # extract the day and normalize @@ -1222,7 +1222,7 @@ class Date(Atomic): day = int(day) if (day == 255): pass - elif day > 34: + elif (day == 0) or (day > 34): raise ValueError("invalid day") # extract the day-of-week and normalize