bug in psycopg2.extras

Karsten Hilbert <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
Witness this:

merkur:/usr/share/pyshared/psycopg2# python
Python 2.5.4 (r254:67916, Jan 24 2010, 12:18:00)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2.extras
>>> psycopg2.extras.register_tstz_w_secs()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/psycopg2/extras.py", line 461, in register_tstz_w_secs
    _ext.register_type(TSTZ_W_SECS, conn_or_curs)
NameError: global name 'TSTZ_W_SECS' is not defined
>>>

The problem is in extras.py:

def register_tstz_w_secs(oids=None, conn_or_curs=None):

...

    if oids is None:
        oids = (1184,) # hardcoded from PostgreSQL headers

    _ext.TSTZ_W_SECS = _ext.new_type(oids, 'TSTZ_W_SECS', _convert_tstz_w_secs)
    _ext.register_type(TSTZ_W_SECS, conn_or_curs)
                       ^^^^^^^^^^^
                       This must be _ext.TSTZ_W_SECS ...

    return _ext.TSTZ_W_SECS


Regards,
Karsten
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
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.