Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105157

Is this an error in python-babel or am I missing something?

From cl@isbd.net
Newsgroups comp.lang.python
Subject Is this an error in python-babel or am I missing something?
Date 2016-03-17 21:32 +0000
Message-ID <tbkrrc-gam.ln1@esprimo.zbmc.eu> (permalink)

Show all headers | View raw


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
ยท

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Is this an error in python-babel or am I missing something? cl@isbd.net - 2016-03-17 21:32 +0000
  Re: Is this an error in python-babel or am I missing something? cl@isbd.net - 2016-03-17 22:40 +0000
    Re: Is this an error in python-babel or am I missing something? Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-17 19:31 -0700
      Re: Is this an error in python-babel or am I missing something? cl@isbd.net - 2016-03-18 10:41 +0000

csiph-web