Skip to content

Commit fb08c8a

Browse files
committed
Add try/except guard for import of CPython rsa library
1 parent e71b438 commit fb08c8a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

adafruit_rsa/key.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,13 @@ def _save_pkcs1_der(self):
270270
from pyasn1.codec.der import encoder
271271
except ImportError as err:
272272
raise ImportError("This functionality requires the library") from err
273-
from rsa.asn1 import AsnPubKey
273+
try:
274+
from rsa.asn1 import AsnPubKey
275+
except ImportError as err:
276+
raise ImportError(
277+
"This functionality requres the CPython rsa library, "
278+
"not available in CircuitPython"
279+
) from err
274280

275281
# Create the ASN object
276282
asn_key = AsnPubKey()

0 commit comments

Comments
 (0)