This project is archived and is in readonly mode.

#7 ✓resolved
Psycopg website

sefault on mogrify with a Decimal

Reported by Psycopg website | November 5th, 2010 @ 05:40 AM | in release-2.3.0

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)

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo November 6th, 2010 @ 01:05 AM

    • 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.

  • Daniele Varrazzo

    Daniele Varrazzo November 9th, 2010 @ 12:30 AM

    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.

  • Daniele Varrazzo

    Daniele Varrazzo November 11th, 2010 @ 01:01 AM

    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.

  • Nate C

    Nate C November 15th, 2010 @ 02:27 AM

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages