skarim / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
http://eventable.github.io/vobject/
254 stars 90 forks source link

VTODO int cannot be int #178

Open tieugene opened 2 years ago

tieugene commented 2 years ago

Code:

import vobject
v = vobject.iCalendar()
v.add('vtodo')
v.vtodo.add('sequence').value = 1
v.serialize()

Result:

...
  File "/usr/local/lib/python3.9/site-packages/vobject/base.py", line 1219, in backslashEscape
    s = s.replace("\\", "\\\\").replace(";", "\;").replace(",", "\,")
AttributeError: 'int' object has no attribute 'replace'
tieugene commented 2 years ago

The same with priority and percent-complete

da4089 commented 6 months ago

The code is expecting a string value.

It seems like it'd be better to accept native integer types for integer values (and floats for floats, etc). I need to look at this a bit more, but superficially, it seems like native type values should be converted to strings, and only native string values should need backslash quoting.

The root of this seems to be that the line (a ContentLine instance) has its behavior set to TextBehavior.