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
[WIP] as_vevent: use vDDDTypes instead of explicit date/datetime type #19
Conversation
This fixes a problem when using the `decoded` method. E.g., `event.decoded('dtstart')` fails with an exception: ``` File ".../.pyenv/lib/python3.7/site-packages/icalendar/cal.py", line 237, in decoded return self._decode(name, value) File ".../.pyenv/lib/python3.7/site-packages/icalendar/cal.py", line 220, in _decode decoded = types_factory.from_ical(name, value) File ".../.pyenv/lib/python3.7/site-packages/icalendar/prop.py", line 1042, in from_ical decoded = type_class.from_ical(value) File ".../.pyenv/lib/python3.7/site-packages/icalendar/prop.py", line 334, in from_ical u = ical.upper() ``` This is due to a type inconsistency between the event created by this package and the type that `icalendar` expects. Another (ugly) workaround for this problem (if this patch was not applied) would be to convert the event to ical and parse it back using `icalendar`, which repairs the dtstart type inconsistency as well (e.g., something like `event = icalendar.Calendar.from_ical(event.to_ical())``
Consider this pull request rather as half an issue: I am not sure whether the tests are indeed supposed to force the specific date/datetime types (which do not seem to be used in that way by |
@wichmannpas Thanks for reporting this - I did not encounter this so I am happy to see that you know about this. Can you add a source code - or best a test - which fails/breaks? Something that can be reproduced that is broken?
|
To use these changes, the tests would also need to be changed. I did not really know about the vDDDType. I evaluate:
I think: If the tests can be changed this way: each event in the test is converted to bytes and back and then, the type is tested, then, they should work without further changes and this is quite nice and practical. |
What do you think?
|
Thanks for the feedback, I will try to have a look at the tests and add a test case for the problem in the next weeks. |
@wichmannpas Thanks! I could remove some unnecessary tests. |
This fixes a problem when using the
decoded
method.E.g.,
event.decoded('dtstart')
fails with an exception:This is due to a type inconsistency between the event created by this
package and the type that
icalendar
expects.Another (ugly) workaround for this problem (if this patch was not
applied) would be to convert the event to ical and parse it back using
icalendar
, which repairs the dtstart type inconsistency as well (e.g.,something like `event = icalendar.Calendar.from_ical(event.to_ical())``