Re: problem with timezone parsing
Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | initd.org |
| Message-ID | <[email protected]> |
Il giorno lun, 02/03/2009 alle 11.30 +0100, Karsten Hilbert ha scritto: > On Mon, Mar 02, 2009 at 09:31:06AM +0100, Federico Di Gregorio wrote: > > > in the process of adding your code to extras.py I found some code I > > don't understand. > > > > Il giorno mer, 25/02/2009 alle 14.00 +0100, Karsten Hilbert ha scritto: > > > def _convert_ts_with_odd_tz(string_value, cursor): > > > try: > > > return DATETIME(string_value, cursor) > > > except (DataError,), exc: > > > if string_value is None: > > > raise > > > > I don't understand how string_value could be None here. If it was None > > before then DATETIME would have just returned None. It is safe to remove > > it or do you know something that I am missing? > That's unlikely :-) > > However, I have *observed* string_value to be None in the > wild, the consequence being that DATETIME threw an exception > (on second thought I should have realized that that hints at > a deeper problem because, yes, it really ought to return > None). So I put in the check such as NOT to retry parsing > with a truncated string value. > > So, all in all, yes, the check should be superfluous -- but > it shouldn't hurt. And it protects the pre-parsing stages > (the truncation) following it from input it cannot handle. Ok. I commited a modified version of your patch that uses different names (I just picked up the shorter name you were using for the type caster and functions) and remove some checks (I don't see why a user with a custom timestamp-like type could not use the new type caster without first putting its oid in DATETIME). federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer [email protected] INIT.D Developer fog-NGVKUo/i/[email protected] Generated by Signify v1.14 [http://www.debian.org/] -- brought to you by One Line Spam _______________________________________________ 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) iEYEABECAAYFAkmrth0ACgkQvcCgrgZGjeuYJgCfYl7cVlhkWYZEfjBN+f+jNWRG jFIAnjN36aFG3OBZ4TkPzJtOO2xHNTml =yUkO -----END PGP SIGNATURE-----