[Sugar-devel] sugar and python-dateutil in Fedora 22

James Cameron quozl at laptop.org
Sun Jan 18 22:15:50 EST 2015


On Mon, Jan 19, 2015 at 02:43:10AM +0000, Peter Robinson wrote:
> The sugar toolkit (for both gtk2 and gtk3) uses python-dateutil and
> they're rebasing it from 1.5 to 2.x, would it be possible for someone
> to review to see if there's any changes needed in the code please?

Checked on Fedora 20, no issues seen.

Method #1, install package python-dateutil-2.2-1.fc22.noarch.rpm,
restart Sugar, test Sugar desktop functions, test my settings, test
journal, test several activities.

Method #2, static analysis; the only use in sugar-toolkit-gtk{,3} is
in a private function _extract_modification_time in
src/sugar3/activity/i18n.py which is for PO file revision date
parsing, and there's no caller of the function in sugar,
sugar-toolkit-gtk3, or the activity set in my builds, or any of the
.py files in /usr/lib/.  (It might be removed as unused?)

Method #3, manual checking of the feature used by the function, with
two of the revision dates in the Record activity PO files, against 2.x;

Python 2.7.5 (default, Nov  3 2014, 14:40:42) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateutil
>>> dateutil.__version__
'2.2'
>>> import dateutil.parser
>>> x='2012-04-16 19:50+0200'
>>> dateutil.parser.parse(x)
datetime.datetime(2012, 4, 16, 19, 50, tzinfo=tzoffset(None, 7200))
>>> import time
>>> time.mktime(dateutil.parser.parse(x).timetuple())
1334605800.0
>>> x='YEAR-MO-DA HO:MI+ZONE'
>>> dateutil.parser.parse(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 748, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 310, in parse
    res, skipped_tokens = self._parse(timestr, **kwargs)
TypeError: 'NoneType' object is not iterable
>>> 

... vs 1.x ...

Python 2.7.5 (default, Nov  3 2014, 14:40:42) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateutil
>>> dateutil.__version__
'1.5'
>>> import dateutil.parser
>>> x='2012-04-16 19:50+0200'
>>> dateutil.parser.parse(x)
datetime.datetime(2012, 4, 16, 19, 50, tzinfo=tzoffset(None, 7200))
>>> import time
>>> time.mktime(dateutil.parser.parse(x).timetuple())
1334605800.0
>>> x='YEAR-MO-DA HO:MI+ZONE'
>>> dateutil.parser.parse(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 697, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 303, in parse
    raise ValueError, "unknown string format"
ValueError: unknown string format
>>> 

The only difference seems to be the response to invalid date.

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list