Skip to content

Commit 985d56c

Browse files
committed
Catch TypeError in validate_mac()
1 parent 405ec7e commit 985d56c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugwise_usb/helpers/util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
import crcmod
88

99
from ..constants import HW_MODELS
10+
from ..exceptions import NodeError
1011

1112
crc_fun = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)
1213

1314

1415
def validate_mac(mac: str) -> bool:
1516
"""Validate the supplied string is in a MAC address format."""
16-
if not re.match("^[A-F0-9]+$", mac):
17+
try:
18+
if not re.match("^[A-F0-9]+$", mac):
19+
return False
20+
except TypeError:
1721
return False
22+
1823
try:
1924
_ = int(mac, 16)
2025
except ValueError:

0 commit comments

Comments
 (0)