INX type="path" mode="file" can return a directory

Summary:

An extension that specifies a <param type="path" mode="file" … /> in its .inx file will receive a directory in the .py file if the user leaves the field empty.

Steps to reproduce:

  • Install the following extension: path-bug.inx path-bug.py
  • Open Inkscape.
  • Go to Extensions → Render → Path Bug Reproducer…
  • Press Apply without selecting a filename.

What happened?

The debug output reads

FILENAME = '/home/pakin/.config/inkscape/extensions'

This is a directory—and not even one that was selected.

What should have happened?

The debug output should have read,

FILENAME = None

or

FILENAME = ''

That is, if the user doesn't select a file, this should be easy and intuitive to test from Python.

Version info

$ inkscape -V
Inkscape 1.0.2 (e86c870879, 2021-01-15)
    Pango version: 1.48.2
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute