inkex: RecursionError in specified_style

Summary:

I received a file from an extension user which contained a path element with no style attribute (defaults to a black fill). This path is within a group with a fill attribute set to currentColor. When the specified_style method is run on the path element, we get a recursion error.

Steps to reproduce:

Here is a simplified extension code

class SpecifiedStyleError(EffectExtension):
    def effect(self):
        # path1 is in a group with a "fill" attribute set to "currentColor"
        # path1 has no style (defaults to black fill)
        path = self.svg.getElementById('path1')
        path.specified_style()

Run the simplified extension code on the attached svg file.

What happened?

Traceback (most recent call last):
  File "[...]specified_style_error.py", line 33, in <module>
    SpecifiedStyle().run()
  File "[...]/inkex/base.py", line 250, in run
    self.save_raw(self.effect())
  File "[...]specified_style_error.py", line 29, in effect
    path.specified_style()

[... recursion removed ...]

    style = element.specified_style()
  File "[...]/inkex/elements/_base.py", line 628, in specified_style
    return Style.specified_style(self)
  File "[...]/inkex/styles.py", line 470, in specified_style
    cascaded = Style.add_inherited(cascaded, parent.specified_style())
  File "[...]/inkex/styles.py", line 241, in add_inherited
    ret[key] = parent[key]
  File "[...]/inkex/styles.py", line 278, in __setitem__
    _ = value.parse_value(self.element)
  File "[...]/inkex/properties.py", line 104, in parse_value
    return self._parse_value(self.value, element)
  File "[...]/inkex/properties.py", line 338, in _parse_value
    return super()._parse_value(value, element)
  File "[...]/inkex/properties.py", line 262, in _parse_value
    style = element.specified_style()
  File "[...]/inkex/elements/_base.py", line 628, in specified_style
    return Style.specified_style(self)
  File "[...]/inkex/styles.py", line 465, in specified_style
    cascaded = Style.cascaded_style(element)
  File "[...]/inkex/styles.py", line 428, in cascaded_style
    styles = list(element.root.stylesheets.lookup_specificity(element.get_id()))
  File "[...]/inkex/elements/_svg.py", line 386, in stylesheets
    for node in self.xpath("//svg:style"):
  File "[...]/inkex/elements/_base.py", line 437, in xpath
    return super().xpath(pattern, namespaces=namespaces)
  File "src/lxml/etree.pyx", line 1594, in lxml.etree._Element.xpath
  File "src/lxml/xpath.pxi", line 259, in lxml.etree.XPathElementEvaluator.__init__
  File "src/lxml/xpath.pxi", line 131, in lxml.etree._XPathEvaluatorBase.__init__
  File "src/lxml/xpath.pxi", line 55, in lxml.etree._XPathContext.__init__
  File "src/lxml/extensions.pxi", line 76, in lxml.etree._BaseContext.__init__
RecursionError: maximum recursion depth exceeded while calling a Python object

What should have happened?

Method should return the style

Sample attachments:

Drawing.svg

Version info

Inkscape 1.3-alpha (7e65aeea18, 2023-05-15)

GLib version:     2.76.2
GTK version:      3.24.37
glibmm version:   2.66.6
gtkmm version:    3.24.7
libxml2 version:  2.10.4
libxslt version:  1.1.37
Cairo version:    1.17.8
Pango version:    1.50.14
HarfBuzz version: 7.3.0

OS version:       Arch Linux