Skip to content

Getting "Unserialize luadata failed" on a .lua file with more than one dict #13

@godlike64

Description

@godlike64

I'm trying to use luadata to read a .lua file which contains dictionaries. The following is a minimum reproducer (the original .lua file is way larger but the structure is pretty much the same and it fails with the same error on the same unexpected character):

$ cat /tmp/syndi2
SYNDICATOR_CONFIG = {
["show_tooltips_on_shift"] = false,
}
SYNDICATOR_DATA = {
["Characters"] = {
}
}

Trying to read this causes:

>>> import luadata
>>> luadata.read("/tmp/syndi2")
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    luadata.read("/tmp/syndi2")
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/godlike/virtualenv/wow/lib/python3.13/site-packages/luadata/io/read.py", line 26, in read
    return unserialize(text, encoding=encoding, multival=False)
  File "/home/godlike/virtualenv/wow/lib/python3.13/site-packages/luadata/serializer/unserialize.py", line 354, in unserialize
    raise Exception(
    ...<2 lines>...
    )
Exception: Unserialize luadata failed on pos 60:
    ,
}
SYNDICATOR
        ^
    unexpected character.
>>> 

Removing either SYNDICATOR_CONFIG or SYNDICATOR_DATA makes it possible to read the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions