LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
377 stars 108 forks source link

Unexpected keyword argument 'hresult' for CardRequestTimeoutException #166

Closed BoLer1 closed 3 months ago

BoLer1 commented 3 months ago

Your system information

Please describe your issue in as much detail as possible:

Describe what you expected should happen.

-> CardRequestTimeoutException should be created and thrown

Describe what did happen.

-> CardRequestTimeoutException throws error on its init

Steps for reproducing this issue:

3.8.11 and 3.12.2 are conda manage environments. Both are naked -> Only Base python, pip and pyscard

I appended a simple snipped for reproduction.

from smartcard.CardType import AnyCardType
from smartcard.CardRequest import CardRequest
from smartcard.Exceptions import CardRequestTimeoutException

cardtype = AnyCardType()
cardrequest = CardRequest(timeout=1, cardType=cardtype)
while (1):
    try:
        cardservice = cardrequest.waitforcard()   
    except CardRequestTimeoutException:
        continue    

Traceback:

Traceback (most recent call last):
  File "blabla\test.py", line 13, in <module>
    cardservice = cardrequest.waitforcard()   
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "blabla\Lib\site-packages\smartcard\CardRequest.py", line 68, in waitforcard
    return self.pcsccardrequest.waitforcard()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "blabla\Lib\site-packages\smartcard\pcsc\PCSCCardRequest.py", line 216, in waitforcard
    raise CardRequestTimeoutException(hresult=hresult)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: CardRequestTimeoutException.__init__() got an unexpected keyword argument 'hresult'
LudovicRousseau commented 3 months ago

The problem should already be fixed in 7711146de5b730978023daa03feb05810d8f0be2

I will make a new release "soon".

LudovicRousseau commented 3 months ago

Version 2.0.9 is available https://pypi.org/project/pyscard/#files