Skip to content

master: RuntimeError: maximum recursion depth exceeded #1085

@notro

Description

@notro

I needed to rebase #1064 on yesterdays pin->number change and my tests started to fail:

pi@cp:~/work/circuitpython/cp-smbusslave/tests $ pytest --board=feather_m0_express --bus=1 smbus/
============================================================== test session starts ===============================================================
platform linux -- Python 3.5.3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/pi/work/circuitpython/cp-smbusslave/tests, inifile:
plugins: repeat-0.5.0, circuitpython-0.0.1
collected 170 items

smbus/test_ads1015_linux.py FFFFFFFFFFE                                                                                                    [  5%]
smbus/test_at24_linux.py ...........................................                                                                       [ 31%]
smbus/test_byte_word.py ................................................................                                                   [ 68%]
smbus/test_ds1307.py FE                                                                                                                    [ 69%]
smbus/test_ds1307_linux.py EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE                                                                       [ 92%]
smbus/test_mcp23008_linux.py EEEEEEEsssssE                                                                                                 [100%]

Exception:

Traceback (most recent call last):
  File "<stdin>", line 34, in <module>
  File "<stdin>", line 4, in ads1015slave_func
  File "/home/pi/circuitpython/i2cslave/disk/ads1015slave.py", line 2, in <module>
  File "/home/pi/circuitpython/i2cslave/disk/smbusslave.py", line 2, in <module>
  File "/home/pi/circuitpython/i2cslave/disk/smbusslave.py", line 6, in SMBusSlave
RuntimeError: maximum recursion depth exceeded

This seems to be the minimum to trigger the exception:

ads1015slave.py:

from smbusslave import SMBusSlave

class ADS1015Slave(SMBusSlave):
    pass

smbusslave.py:

class SMBusSlave:
    pass

Importing ads1015slave inside a function fails:

Adafruit CircuitPython 4.0.0-alpha-918-gdfa2581ff on 2018-08-03; Adafruit Feather M0 Express with samd21g18
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== def func():
===     import ads1015slave
===
=== func()
===
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "<stdin>", line 2, in func
  File "ads1015slave.py", line 1, in <module>
  File "smbusslave.py", line 2, in <module>
RuntimeError: maximum recursion depth exceeded
>>>

Importing directly is fine:

Adafruit CircuitPython 4.0.0-alpha-918-gdfa2581ff on 2018-08-03; Adafruit Feather M0 Express with samd21g18
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import ads1015slave
=== print(dir(ads1015slave))
===
['__file__', '__name__', 'SMBusSlave', 'ADS1015Slave']
>>>

Importing smbusslave inside a function is fine:

Adafruit CircuitPython 4.0.0-alpha-918-gdfa2581ff on 2018-08-03; Adafruit Feather M0 Express with samd21g18
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== def func():
===     import smbusslave
===     print(dir(smbusslave))
===
=== func()
===
['__file__', '__name__', 'SMBusSlave']
>>>

The tests passed when I was based on this commit:

commit 1fb81979b22a48c0933850f786e716a952d42c84 (tag: patchbase, tag: 4.0.0-alpha, origin/master, origin/HEAD, master)
Merge: 617351aeb bb28faf39
Author: arturo182 <[email protected]>
Date:   Wed Jul 18 09:03:56 2018 +0200

    Merge pull request #1036 from hathach/fix_nrf52840_serial

    Fix nrf52840 serial mentioned #1021

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions