Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when serializing int values #7

Open
dimaspivak opened this issue Feb 15, 2017 · 2 comments
Open

AttributeError when serializing int values #7

dimaspivak opened this issue Feb 15, 2017 · 2 comments

Comments

@dimaspivak
Copy link
Contributor

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?

@jleclanche
Copy link
Member

Yeah, probably a good idea to str() stuff when you set it.

@dimaspivak
Copy link
Contributor Author

Can the module be updated to put values through str() automatically when serializing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants