mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.95k stars 563 forks source link

Handle bytes in the attrs_before parameter for pyodbc.connect() #1290

Closed keitherskine closed 1 year ago

keitherskine commented 1 year ago

An attempt to fix the segfault issue #1289 .

It looks like the code to handle byte values in the attrs_before parameter was lost in the v5 upgrade. I've copied the original code back in. The only difference is I've replaced the call to PyBytes_AS_STRING with the stable ABI compliant call to PyBytes_AsString.

@mkleehammer / @v-chojas / @gordthompson , I haven't been able to properly test this though, so do please check what I've done.

mkleehammer commented 1 year ago

@keitherskine Thanks for this. I believe when I was porting I was thinking everything should be text and I should take out bytes.

BTW, after this is merged, I should probably add an error to say "type XXX is not supported". If that existed before, people would have seen "type bytes is not supported" and would have sped up the process of troubleshooting.

mkleehammer commented 1 year ago

Ha. The new error message I added would not have helped in this case. One of the checks below is for a sequence, which bytes are. Thanks again.