File: pyscard-compatibility.patch

package info (click to toggle)
python-fido2 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,408 kB
  • sloc: python: 10,411; javascript: 181; sh: 21; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
commit e2eb7d4a52a762795c1a8aa9804f184b11b5e64d
Author: Dain Nilsson <dain@yubico.com>
Date:   Mon Apr 14 13:20:17 2025 +0200

    Support pyscard >=2.2.2

--- a/fido2/pcsc.py
+++ b/fido2/pcsc.py
@@ -34,7 +34,6 @@
 from smartcard import System
 from smartcard.CardConnection import CardConnection
 from smartcard.pcsc.PCSCExceptions import ListReadersException
-from smartcard.pcsc.PCSCContext import PCSCContext
 
 from threading import Event
 from typing import Tuple, Optional, Callable, Iterator
@@ -243,9 +242,15 @@
 def _list_readers():
     try:
         return System.readers()
-    except ListReadersException:
+    except ListReadersException as e:
         # If the PCSC system has restarted the context might be stale, try
         # forcing a new context (This happens on Windows if the last reader is
         # removed):
-        PCSCContext.instance = None
-        return System.readers()
+        try:
+            from smartcard.pcsc.PCSCContext import PCSCContext
+
+            PCSCContext.instance = None
+            return System.readers()
+        except ImportError:
+            # As of pyscard 2.2.2 the PCSCContext singleton has been removed
+            raise e