Skip to content

AttributeError when serializing int values #7

@dimaspivak

Description

@dimaspivak

After loading in a properties file, if I use __setitem__ to set a value to a non-string (e.g. prop['http.port'] = 7180), I get an attribute error upon trying to serialize my Properties instance with str(). That is,

str(props)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/site-packages/jproperties.py", line 58, in __str__
    ret.append(self.escape_key(node.key) + node.separator + self.escape(node.value))
  File "/usr/lib/python3.5/site-packages/jproperties.py", line 81, in escape
    return value.encode("unicode_escape").decode("utf-8")
AttributeError: 'int' object has no attribute 'encode'

Perhaps a forced cast should be introduced somewhere in the escape chain?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions