Skip to content

Not serializable PosixPath when exporting JSON #657

@tomvdbussche

Description

@tomvdbussche

Exporting the JSON (using --export-json) for some projects (e.g. examples/vhdl/run) throws the following exception:

Traceback (most recent call last):
  File "/home/tom/git/vunit/vunit/ui/__init__.py", line 726, in main
    all_ok = self._main(post_run)
  File "/home/tom/git/vunit/vunit/ui/__init__.py", line 761, in _main
    return self._main_export_json(self._args.export_json)
  File "/home/tom/git/vunit/vunit/ui/__init__.py", line 892, in _main_export_json
    json.dump(json_data, fptr, sort_keys=True, indent=4, separators=(",", ": "))
  File "/usr/lib64/python3.8/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/usr/lib64/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib64/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.8/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib64/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib64/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type PosixPath is not JSON serializable

This is when running on Linux, but it seems to be a problem on Windows as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions