Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

PyPy support #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -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

11 changes: 8 additions & 3 deletions python/umysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
16 changes: 9 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,22 @@
Programming Language :: Python
Topic :: Database
Topic :: Software Development :: Libraries :: Python Modules
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
""".splitlines()))

"""
try:
shutil.rmtree("./build")
except(OSError):
pass
"""
"""

libs = []

if sys.platform != "win32":
libs.append("stdc++")

if sys.platform == "win32":
libs.append("ws2_32")

Expand All @@ -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="[email protected]",
download_url="http://github.com/esnme/ultramysql",
license="BSD License",
platforms=['any'],
platforms=['any'],
url="http://www.esn.me",
classifiers=CLASSIFIERS,
)
)