From 4eecc130bdaf68a9f250230efcabe1f0a0598cf0 Mon Sep 17 00:00:00 2001 From: Jason Madden Date: Sun, 29 Mar 2015 10:54:42 -0500 Subject: [PATCH 1/2] Make build and install under PyPy. Replaces PyObject_Malloc/Free with their PyMem counterparts; PyPy does not support the PyObject variants. Arguably, based on https://docs.python.org/2.3/whatsnew/section-pymalloc.html the PyMem variants are a better fit for this use case anyway (PyObject_ being intended for "small" allocations). Disables the use of CP1250 under PyPy because it lacks the PyUnicode_Encode function. There are no new tests failures. (testConnectWithWrongDB fails with a 1044 error for me and not 1049 with both the original code under CPython and this code under PyPy). --- python/umysql.c | 11 ++++++++--- setup.py | 16 +++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/python/umysql.c b/python/umysql.c index 2564e97..c568ed3 100644 --- a/python/umysql.c +++ b/python/umysql.c @@ -769,11 +769,12 @@ PyObject *Connection_isConnected(Connection *self, PyObject *args) Py_RETURN_FALSE; } +#ifndef PYPY_VERSION PyObject *PyUnicode_EncodeCP1250Helper(const Py_UNICODE *data, Py_ssize_t length, const char *errors) { return PyUnicode_Encode (data, length, "cp1250", errors); } - +#endif PyObject *HandleError(Connection *self, const char *funcName) { @@ -878,8 +879,12 @@ PyObject *Connection_connect(Connection *self, PyObject *args) else if (strcmp (pstrCharset, "cp1250") == 0) { +#ifndef PYPY_VERSION self->charset = MCS_cp1250_general_ci; self->PFN_PyUnicode_Encode = PyUnicode_EncodeCP1250Helper; +#else + return PyErr_Format (PyExc_ValueError, "Unsupported character set '%s' specified", pstrCharset); +#endif } else if (strcmp (pstrCharset, "utf8mb4") == 0) @@ -1093,7 +1098,7 @@ PyObject *EscapeQueryArguments(Connection *self, PyObject *inQuery, PyObject *it { /* FIXME: Allocate a PyString and resize it just like the Python code does it */ - obuffer = (char *) PyObject_Malloc(cbOutQuery); + obuffer = (char *) PyMem_Malloc(cbOutQuery); heap = 1; } else @@ -1124,7 +1129,7 @@ PyObject *EscapeQueryArguments(Connection *self, PyObject *inQuery, PyObject *it if (*iptr != 's' && *iptr != '%') { Py_DECREF(iterator); - if (heap) PyObject_Free(obuffer); + if (heap) PyMem_Free(obuffer); return PyErr_Format (PyExc_ValueError, "Found character %c expected %%", *iptr); } diff --git a/setup.py b/setup.py index 81383bc..58b6918 100644 --- a/setup.py +++ b/setup.py @@ -68,6 +68,8 @@ Programming Language :: Python Topic :: Database Topic :: Software Development :: Libraries :: Python Modules +Programming Language :: Python :: Implementation :: CPython +Programming Language :: Python :: Implementation :: PyPy """.splitlines())) """ @@ -75,13 +77,13 @@ shutil.rmtree("./build") except(OSError): pass -""" - +""" + libs = [] if sys.platform != "win32": libs.append("stdc++") - + if sys.platform == "win32": libs.append("ws2_32") @@ -92,16 +94,16 @@ library_dirs = [], libraries=libs, define_macros=[('WIN32_LEAN_AND_MEAN', None)]) - + setup (name = 'umysql', - version = "2.61", + version = "2.62.dev0", description = "Ultra fast MySQL driver for Python", ext_modules = [module1], author="Jonas Tarnstrom", author_email="jonas.tarnstrom@esn.me", download_url="http://github.com/esnme/ultramysql", license="BSD License", - platforms=['any'], + platforms=['any'], url="http://www.esn.me", classifiers=CLASSIFIERS, - ) + ) From 5f61e90fba189b30d99c2af5db1520162d07f039 Mon Sep 17 00:00:00 2001 From: Jason Madden Date: Mon, 8 Jul 2019 15:41:16 -0500 Subject: [PATCH 2/2] Docs-deprecate because of https://github.com/zodb/relstorage/issues/264 --- README | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README b/README index d36779a..9a655e8 100644 --- a/README +++ b/README @@ -1,10 +1,12 @@ +:: WARNING :: +This driver is no longer supported or recommended. See https://github.com/zodb/relstorage/issues/264 + :: Description :: -A fast MySQL driver written in pure C/C++ for Python. +A fast MySQL driver written in pure C/C++ for Python. Compatible with gevent through monkey patching :: Requirements :: -Requires Python (http://www.python.org) +Requires Python (http://www.python.org) :: Installation :: python setup.py build install -