Skip to content

SystemError when trying to serialize a dictionary with non-string keys #12

@MichaelSquires

Description

@MichaelSquires

Hi, I ran across this error today which seems like a bug:

$ python -c "import yyjson; yyjson.dumps({'a':'a', 2:2})"
TypeError: bad argument type for built-in operation

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "~/.pyenv/versions/3.11.7/lib/python3.11/site-packages/yyjson/__init__.py", line 71, in dumps
    return Document(obj, default=default).dumps()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: <class 'cyyjson.Document'> returned a result with an exception se

The preferred behavior here would probably be to raise a ValueError with a descriptive message about the dict key not being a string.

This was tested with py_yyjson v4.0.6 from pypi.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions