beets icon indicating copy to clipboard operation
beets copied to clipboard

Using Inline to [re]define default fields causes "maximum recursion depth exceeded"

Open RollingStar opened this issue 8 years ago • 4 comments

Problem

Another semi-silly one. Users can probably guess that this is a bad idea, but I tried it anyway.

This happens after telling import to [R]emove old:

[many more lines like the following]
  File "beets\beetsplug\inline.py", line 102, in _dict_for
    out = dict(obj)
  File "beets\beets\dbcore\db.py", line 237, in __getitem__
    return getters[key](self)
  File "beets\beetsplug\inline.py", line 120, in _func_func
    func.__globals__.update(_dict_for(obj))
  File "beets\beetsplug\inline.py", line 102, in _dict_for
    out = dict(obj)
  File "beets\beets\dbcore\db.py", line 237, in __getitem__
    return getters[key](self)
  File "beets\beetsplug\inline.py", line 120, in _func_func
    func.__globals__.update(_dict_for(obj))
  File "beets\beetsplug\inline.py", line 102, in _dict_for
    out = dict(obj)
  File "beets\beets\dbcore\db.py", line 281, in keys
    base_keys = list(self._fields) + list(self._values_flex.keys())
RecursionError: maximum recursion depth exceeded while calling a Python object

Led to this problem:

album_fields:
   album: |
        return 'asdf'

Setup

  • OS: Win10 x64 Powershell
  • Python version: 3.6.0
  • beets version: 1.4.4+ (git intermediate before 1.4.5)
  • Turning off plugins made problem go away (yes/no): probably

When I have beets like this, it lists two "album" fields in beet fields.

Potential fix

Maybe quit beets with an error message about using the same fields as beets defaults?

RollingStar avatar Jun 25 '17 23:06 RollingStar

Thanks! That's a pretty clear problem: to compute the value of album, beets is trying to use the value of album. 🙄 We may even be able to support this by cutting the recursion cycle.

sampsyo avatar Jun 26 '17 12:06 sampsyo

Just stumbled upon this issue after trying the following:

item_fields:
    original_year: original_year if original_year > 0 else year
album_fields:
    original_year: original_year if original_year > 0 else year

So, the only workaround to fix a missing value is adding a custom field?

zhelezov avatar Oct 16 '17 09:10 zhelezov

Indeed; choosing a new name will work.

sampsyo avatar Oct 16 '17 12:10 sampsyo

Just a heads up, this also affects beet update. Had to disable the inline plugin entirely to get anything to work again.

jslpc avatar Aug 03 '24 23:08 jslpc