From: SourceForge.net <no...@so...> - 2005-04-08 03:10:19
|
Bugs item #1178976, was opened at 2005-04-08 03:10 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=1178976&group_id=16528 Category: PgResult Group: None Status: Open Resolution: None Priority: 5 Submitted By: Ben Rampling (benr_web) Assigned to: Nobody/Anonymous (nobody) Summary: unQuoteBytea adds an extraneous NUL byte Initial Comment: "unQuoteBytea" in libpqmodule.c was modified between release 2.4 and the current CVS version. The function starts: PyObject *unQuoteBytea(char *sin) { int i, j, slen, byte; char *sout; PyObject *result; slen = strlen(sin) + 1; /* ! */ In release 2.4 the last line was: slen = strlen(sin); As a result of this change, if you do: cursor.execute("SELECT 'Quick Brown'::bytea") and then print the result, you get: 'Quick Brown\x00' In the release version 2.4, you get what I would expect: 'Quick Brown' Looking at all of unQuoteBytea, it looks quite safe to just remove the + 1. The entire function treats sout as a memory buffer possibly containing null characters, with the length in slen. Py_BuildValue is using "s#" as the format and doesn't require or want any terminator. Perhaps this happened when the fixes for libPQquoteBytea were being applied? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=1178976&group_id=16528 |