Skip to content

Infinite recursion when run without correct permissions #5

@Phasip

Description

@Phasip

On latest git version
commit 25ee90ed9d65c42973be361d22f60b450d22b8dd (HEAD -> master, origin/master, origin/HEAD)

If I try to use the 'is_card_inserted' command without correct permissions it fails doing infinite recursion on getattr.

develop@ubuntu:~/LeiaStuff/smartleia$ python3
Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smartleia as sl
>>> reader = sl.LEIA()
>>> reader.is_card_inserted()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/develop/LeiaStuff/smartleia/smartleia/__init__.py", line 1023, in is_card_inserted
    self._send_command(b"?")
  File "/home/develop/LeiaStuff/smartleia/smartleia/__init__.py", line 1093, in _send_command
    self._testWaitingFlag()
  File "/home/develop/LeiaStuff/smartleia/smartleia/__init__.py", line 711, in _testWaitingFlag
    self.ser.read_all()
  File "/home/develop/LeiaStuff/smartleia/smartleia/__init__.py", line 1107, in __getattr__
    if hasattr(self.ser, attr):
  File "/home/develop/LeiaStuff/smartleia/smartleia/__init__.py", line 1107, in __getattr__
    if hasattr(self.ser, attr):
  File "/home/develop/LeiaStuff/smartleia/smartleia/__init__.py", line 1107, in __getattr__
    if hasattr(self.ser, attr):
  [Previous line repeated 993 more times]
RecursionError: maximum recursion depth exceeded

When running under sudo everything is nice and dandy.

develop@ubuntu:~/LeiaStuff/smartleia$ sudo python3
Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smartleia as sl
>>> sl
KeyboardInterrupt
>>> reader = sl.LEIA()
read>>> reader.is_card_inserted()
True
>>> reader.is_card_inserted()
True
>>> reader.is_card_inserted()
False
>>> 

A clearer error would be preferable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions