-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fdb decodes message with a system encoding while it`s encoded using server encoding #105
Comments
I ran into the same problem, having |
I went though a similar bug, I've solved it adding the "replace" option to the decode function |
Apologies for bumping an old issue. We've also had to deal with this problem in 2024. We have both a Python backend and a Firebird 4 DB running on Linux. The database is encoded using We've held off on changing over to the new Python driver due to an issue with how BLOBs are handled and how that relates to the SQLAlchemy driver for Firebird. I admit that we haven't tested whether this is actually the case, but having a look at the new driver's source code, it seems to also suffer from this issue, since it uses The proposed solutions have some problems:
The solution we've found works best for our case is to use the same encoding as the connection to the database, since it's more likely that the database will also use that encoding for its exceptions. This means that, in
591c591
< def exception_from_status(error, status, preamble=None):
---
> def exception_from_status(error, status, preamble=None, encoding=None):
607c607
< msglist.append('- ' + (msg.value).decode(sys_encoding))
---
> msglist.append("- " + (msg.value).decode(charset_map.get(encoding, encoding) or sys_encoding))
We do have a patch file for fixing this issue, which can be applied to |
Well, the core of this problem is that there could be error messages that are encoded in OS encoding at the server (path, filenames etc.). In your case it happens to be the same as database encoding, so your solutions works fine for you, but fails for other cases. Hence I'm reluctant to adopt this approach. I agree that this should be configurable, best at connection level (both database and server). I'll see what I can do about that, but I'll first fix that in |
How to reproduce:
Firebird 2.0
underWindows 10
(default charset isCP1251
)python3
underLinux
(default charset isUTF-8
) withfdb==2.0.2
'utf-8' codec can't decode byte 0xf2 in position 0: invalid continuation byte
errorStacktrace points into a
fbcore.py:607
Probably, the solution can be to use a
charset
option from theconnect
method here but have no idea how to do thisThe text was updated successfully, but these errors were encountered: