-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Strong types, not ignoring the VALUE parameter, better error handling #196
Conversation
I will leave running your Jenkins jobs on you if you don't mind. |
It would seem those tests failed if I see the right jobs. Also, there should probably be better notification of test failure in the Pull Request report. |
@gforcada I believe the Internet revealed the string that should have made the test fail which is the one in test_portal_ical on Plone:tests.test_icalendar/. However, it does not seem to fail for me. |
src/icalendar/prop.py
Outdated
@staticmethod | ||
def from_ical(ical, timezone=None): | ||
@classmethod | ||
def from_ical(cls, ical, unit_type=None, timezone=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the old order of arguments, this breaks backwards compatibility otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that wasn't clever at all, don't know why I did that. Should be fixed now.
c01d381
to
9c5de10
Compare
@gforcada I fixed the issue pointed out by @geier in a comment and decided to go ahead and run a Jenkins job according to the guide. Allowed the application to read whatever it wanted to read and I suddenly get "stlaz is missing the Overall/Read permission" on http://jenkins.plone.org/. This seems a bit funny to me because I have more read permissions as an anonymous user (when I'm not logged in). |
@stlaz probably that's related to you not being in github.com/plone organization I think... I will run the jobs for you |
Still not sure why the IcalendarTestExportDX tests are failing, I was thinking they would be caused by the backward compatibility issues which I was hoping I fixed. |
I've created https://github.com/geier/icalendar/tree/fix_failures to help pinpoint those errors. |
src/icalendar/prop.py
Outdated
@@ -402,6 +429,10 @@ def from_ical(ical, timezone=None): | |||
tzinfo = _timezone_cache.get(timezone, None) | |||
|
|||
try: | |||
if ical[8] != 'T': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for length here
ignore that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will swap this check with the length check to make it a bit cleaner.
9c5de10
to
b257aa5
Compare
Thanks @geier, that helped! I was able to find the issues with the decoded() method. Still not able to reproduce the IcalendarTestExportDX issue. |
@thet: This time it helped to reveal a bug so I was happy we had it there :) But you, Plone, can always run those tests yourself and open an Issue if something is broken by my patches, mark me as an Assignee and I shall have a look at it. That seems a bit more reasonable than having CI tests that the community can't run anyway. |
@stlaz sorry, somehow I didn't see your replies, I know these the test data isn't RFC5545 compliant, but it's what the plone people use, so I'm sure they wouldn't appreciate it if we broke this in a non-major release. And yes, this is somewhat inconsistent with the behavior of icalendar in other places, like only accepting timeshifts for VTIMEZONE components <= 24h. I'm actually in favor of some kind of |
@geier If I recall correctly, originally this patch enabled lazier approach to parsing iCalendar strings, leaving strange values at the given property as strings, while also keeping the property parameters. This should allow the user of the parser to evaluate the value according to their needs instead of parsing it in a wrong way and possibly dropping some of the parameters on the way. |
I fully agree, but at the moment I do not have a lot of time for this. |
Previously, if error occured during the creation of inner type instance from iCalendar string, the error with the name of the bogus property would be stored in the appropriate component's errors attribute along with the error string but the property's value would be removed from the parsed representation. This patch keeps the value even with its parameters at that certain property, the value's type is changed to vText. Should allow implementation of collective#158 Improves collective#174
for dt in dt_list: | ||
dt = vDDDTypes(dt) | ||
# raise ValueError if type of the input values differs | ||
if not isinstance(dt, ltype): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this test fail if the first element in the list is a date and the later ones are datetime? I believe we will need to actually do a if type(dt) != type(ltype)
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, you're right, it would seem that we need to be even more strict here. Thanks for pointing that out with the date
/datetime
example, I did not realize.
I have used khal's testsuite as an additional test for this PR and while I have found an issue, minimal example as follows: import icalendar
import datetime as dt
event = icalendar.Event()
event.add('DTSTART', dt.date.today())
event.to_ical() leads to an AttributeError:
|
Documentation issue: accessing a DURATION's timedelta changed from |
The documentation issue did not appear in this PR for the first time though, did it? |
I believe it does, the following snippet works on master but not with this PR: import icalendar
import datetime as dt
event = icalendar.Event()
event.add('DURATION', dt.timedelta(hours=2))
print(event['DURATION'].dt) |
Hello, I believe the I need to look more closely on the first issue though. It's apparent that |
I am sorry I did not get enough time for this for the past few months, a lot happened. I should hope to get to this real soon, hopefully. A note to the failure with the simple example |
Hello,
Long time no patch from me so I decided it might be good to finally improve error handling. I built the error handling improvements on top of #192 as I believe this patch may finally get it pushed.