Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: cl@isbd.net Newsgroups: comp.lang.python Subject: Is this an error in python-babel or am I missing something? Date: Thu, 17 Mar 2016 21:32:13 +0000 Lines: 30 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net HtkutWW2JsU/Dpcl0ajW+AaFc/9on2jXrNMlfFhx/iWgKR+xU= X-Orig-Path: not-for-mail Cancel-Lock: sha1:e39uiyg86tP5CrK/u8BH9gpbQkY= User-Agent: tin/2.3.1-20141224 ("Tallant") (UNIX) (Linux/4.2.0-34-generic (x86_64)) Xref: csiph.com comp.lang.python:105157 I am getting the following error when running some code that uses python-sqlkit. This uses python-babel to handle dates for different locales. Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/sqlkit-0.9.6.1-py2.7.egg/sqlkit/widgets/table/columns.py", line 169, in cell_data_func_cb formatted_value = self.field.format_value(value) File "/usr/local/lib/python2.7/dist-packages/sqlkit-0.9.6.1-py2.7.egg/sqlkit/fields.py", line 1114, in format_value return dates.format_date(value, format=format or self.format, locale=self.locale) File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 569, in format_date return pattern.apply(date, locale) File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 892, in apply return self % DateTimeFormat(datetime, locale) File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 889, in __mod__ return self.format % other File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 948, in __getitem__ return self.format_milliseconds_in_day(num) File "/usr/lib/python2.7/dist-packages/babel/dates.py", line 1029, in format_milliseconds_in_day self.value.minute * 60000 + self.value.hour * 3600000 AttributeError: 'datetime.date' object has no attribute 'microsecond' I'm handling a date in my sqlite database, *not* a datetime. The sqlkit code seems to be calling the correct method - format_date() - in the python-babel dates.py file. However it seems that python-babel ends up trying to hand the date down to a method that's expecting a datetime. I've tried searching for reports of this error but I can't see any which makes me wonder if it's not a bug in python-babel, however if it's not a bug then I'm confused about what has gone wrong. Is it a bug or is sqlkit doing something wrong? -- Chris Green ยท