Skip to content

Gtk.Template: Accept PathLike objects as a filename

An attempt to pass a Path object as a filename results in a TypeError: "Must be bytes, not PosixPath". A simple way to accept Path objects would be unconditionally turning them into str, but since native paths may be bytes as well, this might break applications relying on being able to bytes-based filename. Instead, test whether the path is a PathLike object and convert it into a string using os.fspath().

Edited by Andrej Shadura

Merge request reports