From naktinis at toostis.com Fri Apr 9 20:05:40 2010 From: naktinis at toostis.com (Rimvydas Naktinis) Date: Fri, 9 Apr 2010 21:05:40 +0300 Subject: [icalendar-dev] Line folding and utf-8 Message-ID: Lines get folded in the middle of multi-octet sequences (checked out code from svn today). Consider this case: import icalendar ical = icalendar.Calendar() ical.add('summary', u'a' + u'?'*100) ical.as_string().decode('utf-8') ... UnicodeDecodeError: 'utf8' codec can't decode bytes in position 90-91: invalid data I have attached a diff of a simple one-line fix. As I see in the code you actually try not to split a multi-octet character but you don't recalculate the slice after finding the new end position. Could you confirm this? -- Rimvydas Naktinis Developer at Toostis.com -------------- next part -------------- Index: icalendar/parser.py =================================================================== --- icalendar/parser.py (revision 73587) +++ icalendar/parser.py (working copy) @@ -456,6 +456,7 @@ else: end -= 1 + slice = self[start:end] new_lines.append(slice) if end == l_line: # Done From naktinis at toostis.com Fri Apr 9 22:26:12 2010 From: naktinis at toostis.com (Rimvydas Naktinis) Date: Fri, 9 Apr 2010 23:26:12 +0300 Subject: [icalendar-dev] Date class identified incorrectly Message-ID: In icalendar.prop.vDDDTypes.__init__ when checking whether object is of type "date" you use: "isinstance(dt, date)". However, since in Python datetime is subclass of date this line incorrectly identifies datetime objects as date objects. I recommend using "type(dt) is date" for this purpose. Attached a diff. -- Rimvydas Naktinis Developer at Toostis.com -------------- next part -------------- Index: icalendar/prop.py =================================================================== --- icalendar/prop.py (revision 73587) +++ icalendar/prop.py (working copy) @@ -586,7 +586,7 @@ wrong_type_used = 0 if wrong_type_used: raise ValueError ('You must use datetime, date or timedelta') - if isinstance(dt, date): + if type(dt) is date: self.params = Parameters(dict(value='DATE')) self.dt = dt