Ticket #24 (assigned defect)

Opened 1 year ago

Last modified 1 year ago

SQL_ASCII encoding passing through to unicode()

Reported by: jdnier@tds.net Assigned to: mfenniak (accepted)
Priority: major Milestone:
Component: pg8000 Version:
Keywords: Cc:

Description

The first database I tried connecting to with pg8000 uses SQL_ASCII for the default encoding. The string 'SQL_ASCII' ends up being passed directly to unicode() as client_encoding, resulting in the following traceback:

>>> db = pg8000.Connection(host='localhost', user='pgsql', database='testdb', port=5435)
>>> cursor = pg8000.Cursor(db)
>>> cursor.execute("select label from tbl_test")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "pg8000.py", line 607, in execute
    self._stmt.execute(*args)
  File "pg8000.py", line 493, in execute
    self._fill_cache()
  File "pg8000.py", line 502, in _fill_cache
    end_of_data, rows = self.c.fetch_rows(self._portal_name, self.row_cache_size, self._row_desc)
  File "pg8000.py", line 1277, in fetch_rows
    rows.append(
  File "pg8000.py", line 1470, in py_value
    return func(v, **kwargs)
  File "pg8000.py", line 1543, in varcharin
    return unicode(data, client_encoding)
LookupError: unknown encoding: SQL_ASCII

I'm using version 1.02.

Change History

03/14/07 22:02:26 changed by mfenniak

  • status changed from new to assigned.

SQL_ASCII corrresponds pretty closely with the Python encoding "ascii", but it is obviously spelt differently. I'll put together a patch to address this bug in the next couple days. I'd like to add support for changing the client_encoding at the same time, as that will allow me to put together unit tests to cover this bug (and test other encoding related issues).