Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

sefault on mogrify with a Decimal

#7

Submitted by: Nate C

after this ...

import psycopg2
from decimal import Decimal

conn = psycopg2.connect('dbname=test')
cursor = conn.cursor()
cursor.mogrify('select %s', (Decimal('3.27'),))

.. python crashes

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32

pyscopg2.version
2.2.2 (dt dec ext pq3)

Reported by Psycopg website · November 5th, 2010 @ 05:40 AM

State: resolved
Milestone: release-2.3.0
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to resolved
    • Milestone set to release-2.3.0
    • Milestone order changed from 4 to 0

    Thank you for the report. I had already refactored mogrify to use more code in common with execute (mostly to support unicode queries) and as a result this bug was fixed. I will add a regression test though.

    In [9]: cursor.mogrify('select %s', (Decimal('3.27'),))
    Out[9]: 'select 3.27'

    Code available in the python2 branch of my git repository http://tinyurl.com/piro-psycopg2 <git://src.develer.com/users/piro/psycopg2.git>, soon to be released.

    November 6th, 2010 @ 01:05 AM

  2. Daniele Varrazzo
    Daniele Varrazzo

    Nate,

    I've found the cause of the crash: the Decimal adapter incorrectly assumed the existence of the is_finite() method: it was actually introduced somewhere after 2.5.1 and is available e.g. in 2.5.4.

    I've fixed the issue in my repos, but the bug is still present in the 2.3.0-beta1. Jason is preparing a Window package.

    November 9th, 2010 @ 12:30 AM

  3. Daniele Varrazzo
    Daniele Varrazzo

    The bug is fixed in the current repository. It only affects Python 2.5.0 and 2.5.1.

    If you want to test on windows, you can use this unofficial build for windows and Python 2.5.

    November 11th, 2010 @ 01:01 AM

  4. Nate C
    Nate C

    Thanks, that worked for me. (I wish they would upgrade python on these machines I have to work on! ;)

    November 15th, 2010 @ 02:27 AM