Opened 7 years ago

Closed 7 years ago

#7090 closed (fixed)

postgresql_psycopg2 blows up when you try to create a cursor with postgresql 8.3.1 on windows

Reported by: grand@… Owned by: nobody
Component: Database layer (models, ORM) Version: 0.96
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


On windows, configured to work with postgresql 8.3.1 creating a cursor blows up due to the format of the postgresql version string.

>>> from django.db import connection
>>> cursor = connection.cursor()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\python25\lib\site-packages\django\db\backends\postgresql_psycopg2\", line 57, in cursor
    postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
ValueError: invalid literal for int() with base 10: '1,'

The version string returned by postgresql was 'PostgreSQL 8.3.1, compiled by Visual C++ build 1400'
It is choking on the comma after the version number. Here is a modified line 57 that fixes the problem:

            postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].replace(',','').split('.')]

Change History (1)

comment:1 Changed 7 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

This is fixed in trunk r7415.

Note: See TracTickets for help on using tickets.
Back to Top