[BUG] Calendar.from_ical() issue
vantro opened this issue · comments
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
Hi, could you attach said calendar? We can't reproduce this atm
The ics file can be downloaded here: https://filesender.renater.fr/?s=download&token=c778975e-6fd1-4146-9426-e3db8e8c59d0
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.
For future notice, it's possible to attach files on Github -- just drag the file into the comment input box :)
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__
.
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.
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.
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.