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

[BUG] Calendar.from_ical() issue #472

Closed
3 tasks done
vantro opened this issue Oct 24, 2022 · 11 comments · Fixed by #473
Closed
3 tasks done

[BUG] Calendar.from_ical() issue #472

vantro opened this issue Oct 24, 2022 · 11 comments · Fixed by #473

Comments

@vantro
Copy link

vantro commented Oct 24, 2022

Hello,
When I try to import an ics file (28Mb) with the following code, the calendar is displayed at the screen without any print() command.

To Reproduce

import icalendar
file="Calendar-2022-10-21-164146"
with open(f'{file}.ics', 'rb') as file:
    ics_text = file.read()
    cal = Calendar.from_ical(ics_text)

Output:

it's a dump of the file

Environment

  • OS: Mac OS Monterey
  • Python version: Python 3.10
  • icalendar version: 5.0.1

How to browse a large file ?

Thanks

@jacadzaca
Copy link
Collaborator

Hi, could you attach said calendar? We can't reproduce this atm

@vantro
Copy link
Author

vantro commented Oct 25, 2022

@jacadzaca
Copy link
Collaborator

jacadzaca commented Oct 25, 2022

Grepping the file for END:VCALENDAR returns nothing, so the file you've attached is invalid. I appened END:VCALENDAR (e.g. echo 'END:VCALENDAR' >> Calendar-2022-10-21-164146) to it, and it was parsed correctly. The dump of the file results from the line 396 of cal.py, where __ repr() __ of a component is appened the error message.

@jacadzaca
Copy link
Collaborator

jacadzaca commented Oct 25, 2022

For future notice, it's possible to attach files on Github -- just drag the file into the comment input box :)

@niccokunzmann
Copy link
Member

I appened END:VCALENDAR

That might happen if a file is incomplete.

The dump of the file results from the line 396 of cal.py, where __ repr() __ of a component is appened the error message.

Hm, maybe it is safe to cut out a few megabytes in __repr__.

@jacadzaca
Copy link
Collaborator

Hm, maybe it is safe to cut out a few megabytes in __repr__.

I created add_max_error_length with a test for error message trimming. If everyone likes it, I can make it green later this week.

@niccokunzmann
Copy link
Member

niccokunzmann commented Oct 26, 2022 via email

@jacadzaca
Copy link
Collaborator

jacadzaca commented Oct 26, 2022

I think 100 characters is fine, since more would obfuscate the fact that an exception was thrown (like we see in this issue). Nonetheless, adding a verbose argument to the Calendar.from_ics method shouldn't be difficult.

@vantro
Copy link
Author

vantro commented Oct 26, 2022

as a user, I don't need to see all the events, but reason of the error is enough.
As this file was generated by an application (Zimbra) a notice the bad structure and the missing argument would be fine.

@niccokunzmann
Copy link
Member

niccokunzmann commented Oct 26, 2022 via email

@jacadzaca
Copy link
Collaborator

@vantro Since the file was produced by a third party program, you should report the bug to them. Feel free to link this issue to them :)

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

Successfully merging a pull request may close this issue.

3 participants