Skip to content

Commit e2eb7d4

Browse files
committed
Support pyscard >=2.2.2
1 parent bf0ddaf commit e2eb7d4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

fido2/pcsc.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from smartcard import System
3535
from smartcard.CardConnection import CardConnection
3636
from smartcard.pcsc.PCSCExceptions import ListReadersException
37-
from smartcard.pcsc.PCSCContext import PCSCContext
3837

3938
from threading import Event
4039
from typing import Callable, Iterator
@@ -243,9 +242,15 @@ def list_devices(cls, name: str = "") -> Iterator[CtapPcscDevice]:
243242
def _list_readers():
244243
try:
245244
return System.readers()
246-
except ListReadersException:
245+
except ListReadersException as e:
247246
# If the PCSC system has restarted the context might be stale, try
248247
# forcing a new context (This happens on Windows if the last reader is
249248
# removed):
250-
PCSCContext.instance = None
251-
return System.readers()
249+
try:
250+
from smartcard.pcsc.PCSCContext import PCSCContext
251+
252+
PCSCContext.instance = None
253+
return System.readers()
254+
except ImportError:
255+
# As of pyscard 2.2.2 the PCSCContext singleton has been removed
256+
raise e

0 commit comments

Comments
 (0)