rigglemania / pysqlcipher3

Python 3 bindings for SQLCipher
zlib License
138 stars 42 forks source link

Import error: undefined symbol: _PyUnicode_AsStringAndSize #26

Open artelse opened 2 years ago

artelse commented 2 years ago

When I try to import sqlcipher from pysqlcipher3 import dbapi2 as sqlcipher, this error is emitted: ImportError: /home/nn/.local/lib/python3.10/site-packages/pysqlcipher3/_sqlite3.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_AsStringAndSize

This is on linux with a compiled sqlcipher: ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \ LDFLAGS="-lcrypto -lsqlite3

Any idea how to resolve?

Q0 commented 2 years ago

Use python 3.8. For Python 3.10, it doesn't work for some reason

artelse commented 2 years ago

According to https://getdocs.org/Python/docs/3.10/whatsnew/3.10, those depricated calls were removed: PEP 624, Remove Py_UNICODE encoder APIs. Here https://www.python.org/download/releases/3.0/whatsnew/ they say:

The undocumented C APIs PyUnicode_AsString() and PyUnicode_AsStringAndSize() were made private to the interpreter, in order to be able to refine their interfaces for Python 3.1.

If you need to access the UTF-8 representation of a Unicode object as bytes string, please use PyUnicode_AsUTF8String() instead.

Hope this is useful?

falkoschindler commented 2 years ago

Yes, for me it worked to replace all occurrences of _PyUnicode_AsStringAndSize with PyUnicode_AsUTF8AndSize everywhere in src/python3/*.c

artelse commented 2 years ago

Great, that worked for me as well. python3 setup.py build then python3 setup.py install