nakagami/pyfirebirdsql — pull request #32 by pmakowski (2012-03-30 13:42:47+00:00)
Title: please watch this change to handle charecter set OCTETS

before the patch :
>>> cur.execute("select gen_uuid() from rdb$database")
>>> print(cur.fetchall())
Traceback (most recent call last):
File "", line 1, in
File "firebirdsql/fbcore.py", line 581, in fetchall
return list(self._fetch_records)
File "firebirdsql/fbcore.py", line 510, in _fetch_generator
stmt_handle, self._xsqlda)
File "firebirdsql/wireprotocol.py", line 615, in _op_fetch_response
r[i] = x.value(raw_value)
File "firebirdsql/fbcore.py", line 218, in value
return self.bytes_to_str(raw_value)
File "firebirdsql/wireprotocol.py", line 250, in bytes_to_str
return b.decode(self.charset_map.get(self.charset, self.charset))
UnicodeDecodeError: 'utf8' codec can't decode byte 0x99 in position 8: invalid start byte

after the patch :
>>> cur.execute("select gen_uuid() from rdb$database")
>>> print(cur.fetchall())
[[b'/\xda\xa5\x1b\x89\xe2\x9f\xff\xd0\x946M\x81\xea\xf2\xc2']]

sorry the commit have more than only the patch, it have also the merge from your code

but you just have to look at def value in class XSQLVAR
the part that take care of sqltype == SQL_TYPE_TEXT and sqltype == SQL_TYPE_VARYING

it is as simple as adding :
elif self.sqlsubtype == 1: # OCTETS
return raw_value