Re: [psycopg] #204: psycopg2 raises TypeError with python 2.5 while reading from binary
"psycopg" <fog-NGVKUo/i/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
#204: psycopg2 raises TypeError with python 2.5 while reading from binary
----------------------+-----------------------------------------------------
Reporter: droc | Owner: fog
Type: defect | Status: closed
Priority: normal | Milestone: PSYCOPG 2.0.7
Component: psycopg2 | Version: 2.0.5
Severity: normal | Resolution: invalid
Keywords: |
----------------------+-----------------------------------------------------
Changes (by jamesh):
* status: reopened => closed
* resolution: => invalid
Comment:
On further investigation, I think this is not a bug.
If we change the last part of your test to:
{{{
>>> f = open("a2.out", "wb")
>>> f.write(r[1])
}}}
Everything works. I don't think it is a bug that the file needs to be
opened in binary mode to write out binary data. If the data was suitable
for writing in text mode, then you wouldn't be storing it as binary in the
database.
If you do wish to treat the data as a string, you can explicitly cast it
with `str(r[1])`.
--
Ticket URL: <http://initd.org/tracker/psycopg/ticket/204#comment:3>
psycopg <http://initd.org/>
psycopg