Re: A real bug!

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <1244669324.4360.4.camel@erin>
Il giorno mer, 10/06/2009 alle 11.57 -0700, Al Niessner ha scritto:
> So, I am now running with psycopg2 and am doing a full load of my
> database and am getting this error:
> 
> dbapi.TimestampFromTicks (timestamp)
> ValueError: second must be in 0..59
> 
> So, I have gone back and am testing with just importing os and
> psycopg2
> and it fails just the same.
> 
> >>> import os
> >>> import psycopg2
> >>> os.path.getatime (fn)
> 1241706839.5885506
> >>> psycopg2.TimeFromTicks (os.path.getatime (fn))
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call
> last)
> ValueError: second must be in 0..59
> 
> So, here is where I am confused as whose bug it is. If psycopg cares
> about rounding at seconds for ticks where the rest of python does not,
> should it not round rather than make me do it? In other words, psycopg
> is massaging the ticks to a timestamp that postgresql will accept so
> it
> should do the rounding and hide the details of postgresql's needs from
> me. Of course, someone will cry that the timestamp does not match
> their
> ticks. Damned if you do and damned if you do not.
> 
> If you want to test, you can always do:
> psycopg2.TimeFromTicks (1241706839.5885506)

This seems to be a real bug. ;) I don't have the time to test the
obvious fix but if you build from source you can try to modify the file
psycopg/adapter_datetime.c around line 396. Change the line:

t = (time_t)round(ticks);

to

t = (time_t)floor(ticks);

and recompile.

Good luck,
federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
 Come sai se il primo è ben dato? In realtà è "Beh il secondo bacio ben
  dato non si rifiuta".                                    -- Alessandra

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkowJYwACgkQvcCgrgZGjess4QCfU3uHp34jVB8/5mGiVH+bKvyG
ElkAn3P/+jHEk8RMYyK/G0Obmap/fXPC
=xqTN
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.