extras/MySQL-python-1.2.3-python3.patch
changeset 18 a9e12b7cc207
equal deleted inserted replaced
17:f768a3529ee7 18:a9e12b7cc207
       
     1 Python3 patch for MySQL-python-1.2.3.
       
     2 Based on https://github.com/davispuh/MySQL-for-Python-3
       
     3 Removed incompatible (and absolutely unnecessary) changes.
       
     4 diff -ru MySQL-python-1.2.3/_mysql.c MySQL-Python-1.2.3-python3/_mysql.c
       
     5 --- MySQL-python-1.2.3/_mysql.c	2010-06-17 09:21:56.000000000 +0200
       
     6 +++ MySQL-Python-1.2.3-python3/_mysql.c	2011-10-05 12:49:58.000000000 +0200
       
     7 @@ -31,33 +31,17 @@
       
     8  #if defined(MS_WINDOWS)
       
     9  #include <winsock2.h>
       
    10  #include <windows.h>
       
    11 -#include <config-win.h>
       
    12 -#else
       
    13 -#include "my_config.h"
       
    14  #endif
       
    15 +#include "my_config.h"
       
    16  #include "mysql.h"
       
    17  #include "mysqld_error.h"
       
    18  #include "errmsg.h"
       
    19  
       
    20 -#if PY_VERSION_HEX < 0x02020000
       
    21 -# define MyTuple_Resize(t,n,d) _PyTuple_Resize(t, n, d)
       
    22 -# define MyMember(a,b,c,d,e) {a,b,c,d}
       
    23 -# define MyMemberlist(x) struct memberlist x
       
    24 -# define MyAlloc(s,t) PyObject_New(s,&t)
       
    25 -# define MyFree(o) PyObject_Del(o)
       
    26 -#else
       
    27  # define MyTuple_Resize(t,n,d) _PyTuple_Resize(t, n)
       
    28  # define MyMember(a,b,c,d,e) {a,b,c,d,e}
       
    29  # define MyMemberlist(x) struct PyMemberDef x
       
    30  # define MyAlloc(s,t) (s *) t.tp_alloc(&t,0)
       
    31 -# define MyFree(ob) ob->ob_type->tp_free((PyObject *)ob) 
       
    32 -#endif
       
    33 -
       
    34 -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
       
    35 -typedef int Py_ssize_t;
       
    36 -#define PY_SSIZE_T_MAX INT_MAX
       
    37 -#define PY_SSIZE_T_MIN INT_MIN
       
    38 -#endif
       
    39 +# define MyFree(ob) ob->ob_base.ob_type->tp_free((PyObject *)ob) 
       
    40  
       
    41  static PyObject *_mysql_MySQLError;
       
    42  static PyObject *_mysql_Warning;
       
    43 @@ -86,7 +70,7 @@
       
    44  
       
    45  typedef struct {
       
    46  	PyObject_HEAD
       
    47 -	PyObject *conn;
       
    48 +	_mysql_ConnectionObject *conn;
       
    49  	MYSQL_RES *result;
       
    50  	int nfields;
       
    51  	int use;
       
    52 @@ -102,17 +86,16 @@
       
    53  #define check_server_init(x) if (!_mysql_server_init_done) _mysql_server_init_done = 1
       
    54  #endif
       
    55  
       
    56 -PyObject *
       
    57 -_mysql_Exception(_mysql_ConnectionObject *c)
       
    58 +PyObject * _mysql_Exception(_mysql_ConnectionObject *c)
       
    59  {
       
    60 -	PyObject *t, *e;
       
    61 +	PyObject *t, *e, *code, *message;
       
    62  	int merr;
       
    63  
       
    64  	if (!(t = PyTuple_New(2))) return NULL;
       
    65  	if (!_mysql_server_init_done) {
       
    66  		e = _mysql_InternalError;
       
    67 -		PyTuple_SET_ITEM(t, 0, PyInt_FromLong(-1L));
       
    68 -		PyTuple_SET_ITEM(t, 1, PyString_FromString("server not initialized"));
       
    69 +		PyTuple_SET_ITEM(t, 0, PyLong_FromLong(-1L));
       
    70 +		PyTuple_SET_ITEM(t, 1, PyUnicode_FromString("server not initialized"));
       
    71  		PyErr_SetObject(e, t);
       
    72  		Py_DECREF(t);
       
    73  		return NULL;
       
    74 @@ -121,8 +104,8 @@
       
    75  	if (!merr)
       
    76  		e = _mysql_InterfaceError;
       
    77  	else if (merr > CR_MAX_ERROR) {
       
    78 -		PyTuple_SET_ITEM(t, 0, PyInt_FromLong(-1L));
       
    79 -		PyTuple_SET_ITEM(t, 1, PyString_FromString("error totally whack"));
       
    80 +		PyTuple_SET_ITEM(t, 0, PyLong_FromLong(-1L));
       
    81 +		PyTuple_SET_ITEM(t, 1, PyUnicode_FromString("error totally whack"));
       
    82  		PyErr_SetObject(_mysql_InterfaceError, t);
       
    83  		Py_DECREF(t);
       
    84  		return NULL;
       
    85 @@ -209,8 +192,12 @@
       
    86  			e = _mysql_OperationalError;
       
    87  		break;
       
    88  	}
       
    89 -	PyTuple_SET_ITEM(t, 0, PyInt_FromLong((long)merr));
       
    90 -	PyTuple_SET_ITEM(t, 1, PyString_FromString(mysql_error(&(c->connection))));
       
    91 +	code = PyLong_FromLong((long)merr);
       
    92 +	message = PyUnicode_FromString(mysql_error(&(c->connection)));
       
    93 +	PyTuple_SET_ITEM(t, 0, code );
       
    94 +	PyTuple_SET_ITEM(t, 1, message );
       
    95 +	PyObject_SetAttrString(e, "code", code );
       
    96 +	PyObject_SetAttrString(e, "message", message );
       
    97  	PyErr_SetObject(e, t);
       
    98  	Py_DECREF(t);
       
    99  	return NULL;
       
   100 @@ -259,7 +246,7 @@
       
   101  		cmd_args_c = (char **) PyMem_Malloc(cmd_argc*sizeof(char *));
       
   102  		for (i=0; i< cmd_argc; i++) {
       
   103  			item = PySequence_GetItem(cmd_args, i);
       
   104 -			s = PyString_AsString(item);
       
   105 +			s = PyBytes_AsString(item);
       
   106  			Py_DECREF(item);
       
   107  			if (!s) {
       
   108  				PyErr_SetString(PyExc_TypeError,
       
   109 @@ -284,7 +271,7 @@
       
   110  		groups_c = (char **) PyMem_Malloc((1+groupc)*sizeof(char *));
       
   111  		for (i=0; i< groupc; i++) {
       
   112  			item = PySequence_GetItem(groups, i);
       
   113 -			s = PyString_AsString(item);
       
   114 +			s = PyBytes_AsString(item);
       
   115  			Py_DECREF(item);
       
   116  			if (!s) {
       
   117  				PyErr_SetString(PyExc_TypeError,
       
   118 @@ -339,7 +326,7 @@
       
   119  	PyObject *flag;
       
   120  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   121  	check_server_init(NULL);
       
   122 -	if (!(flag=PyInt_FromLong((long)mysql_thread_safe()))) return NULL;
       
   123 +	if (!(flag=PyLong_FromLong((long)mysql_thread_safe()))) return NULL;
       
   124  	return flag;
       
   125  }
       
   126  #endif
       
   127 @@ -372,7 +359,7 @@
       
   128  		return -1;
       
   129  	if (!conv) conv = PyDict_New();
       
   130  	if (!conv) return -1;
       
   131 -	self->conn = (PyObject *) conn;
       
   132 +	self->conn = conn;
       
   133  	Py_INCREF(conn);
       
   134  	self->use = use;
       
   135  	Py_BEGIN_ALLOW_THREADS ;
       
   136 @@ -392,7 +379,7 @@
       
   137  	fields = mysql_fetch_fields(result);
       
   138  	for (i=0; i<n; i++) {
       
   139  		PyObject *tmp, *fun;
       
   140 -		tmp = PyInt_FromLong((long) fields[i].type);
       
   141 +		tmp = PyLong_FromLong((long) fields[i].type);
       
   142  		if (!tmp) return -1;
       
   143  		fun = PyObject_GetItem(conv, tmp);
       
   144  		Py_DECREF(tmp);
       
   145 @@ -413,8 +400,8 @@
       
   146  					PyObject *pmask=NULL;
       
   147  					pmask = PyTuple_GET_ITEM(t, 0);
       
   148  					fun2 = PyTuple_GET_ITEM(t, 1);
       
   149 -					if (PyInt_Check(pmask)) {
       
   150 -						mask = PyInt_AS_LONG(pmask);
       
   151 +					if (PyNumber_Check(pmask)) {
       
   152 +						mask = PyLong_AS_LONG(pmask);
       
   153  						if (mask & fields[i].flags) {
       
   154  							Py_DECREF(t);
       
   155  							break;
       
   156 @@ -440,7 +427,6 @@
       
   157  	return 0;
       
   158  }
       
   159  
       
   160 -#if PY_VERSION_HEX >= 0x02020000
       
   161  static int _mysql_ResultObject_traverse(
       
   162  	_mysql_ResultObject *self,
       
   163  	visitproc visit,
       
   164 @@ -451,10 +437,9 @@
       
   165  		if (!(r = visit(self->converter, arg))) return r;
       
   166  	}
       
   167  	if (self->conn)
       
   168 -		return visit(self->conn, arg);
       
   169 +		return visit((PyObject *)self->conn, arg);
       
   170  	return 0;
       
   171  }
       
   172 -#endif
       
   173  
       
   174  static int _mysql_ResultObject_clear(
       
   175  	_mysql_ResultObject *self)
       
   176 @@ -515,7 +500,7 @@
       
   177  		return -1;
       
   178  
       
   179  #define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\
       
   180 -        if(t){d=PyString_AsString(t);Py_DECREF(t);}\
       
   181 +        if(t){d=PyBytes_AsString(t);Py_DECREF(t);}\
       
   182          PyErr_Clear();}
       
   183  
       
   184  	if (ssl) {
       
   185 @@ -663,7 +648,6 @@
       
   186  	return (PyObject *) c;
       
   187  }
       
   188  
       
   189 -#if PY_VERSION_HEX >= 0x02020000
       
   190  static int _mysql_ConnectionObject_traverse(
       
   191  	_mysql_ConnectionObject *self,
       
   192  	visitproc visit,
       
   193 @@ -673,7 +657,7 @@
       
   194  		return visit(self->converter, arg);
       
   195  	return 0;
       
   196  }
       
   197 -#endif
       
   198 +
       
   199  
       
   200  static int _mysql_ConnectionObject_clear(
       
   201  	_mysql_ConnectionObject *self)
       
   202 @@ -862,7 +846,7 @@
       
   203  #endif
       
   204  	Py_END_ALLOW_THREADS
       
   205  	if (err > 0) return _mysql_Exception(self);
       
   206 -	return PyInt_FromLong(err);
       
   207 +	return PyLong_FromLong(err);
       
   208  }		
       
   209  
       
   210  #if MYSQL_VERSION_ID >= 40100
       
   211 @@ -885,7 +869,7 @@
       
   212  	err = mysql_set_server_option(&(self->connection), flags);
       
   213  	Py_END_ALLOW_THREADS
       
   214  	if (err) return _mysql_Exception(self);
       
   215 -	return PyInt_FromLong(err);
       
   216 +	return PyLong_FromLong(err);
       
   217  }		
       
   218  
       
   219  static char _mysql_ConnectionObject_sqlstate__doc__[] =
       
   220 @@ -906,7 +890,7 @@
       
   221  	PyObject *args)
       
   222  {
       
   223  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   224 -	return PyString_FromString(mysql_sqlstate(&(self->connection)));
       
   225 +	return PyUnicode_FromString(mysql_sqlstate(&(self->connection)));
       
   226  }		
       
   227  
       
   228  static char _mysql_ConnectionObject_warning_count__doc__[] =
       
   229 @@ -921,7 +905,7 @@
       
   230  	PyObject *args)
       
   231  {
       
   232  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   233 -	return PyInt_FromLong(mysql_warning_count(&(self->connection)));
       
   234 +	return PyLong_FromLong(mysql_warning_count(&(self->connection)));
       
   235  }		
       
   236  
       
   237  #endif
       
   238 @@ -939,7 +923,7 @@
       
   239  {
       
   240  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   241  	check_connection(self);
       
   242 -	return PyInt_FromLong((long)mysql_errno(&(self->connection)));
       
   243 +	return PyLong_FromLong((long)mysql_errno(&(self->connection)));
       
   244  }
       
   245  
       
   246  static char _mysql_ConnectionObject_error__doc__[] =
       
   247 @@ -955,7 +939,7 @@
       
   248  {
       
   249  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   250  	check_connection(self);
       
   251 -	return PyString_FromString(mysql_error(&(self->connection)));
       
   252 +	return PyUnicode_FromString(mysql_error(&(self->connection)));
       
   253  }
       
   254  
       
   255  static char _mysql_escape_string__doc__[] =
       
   256 @@ -966,18 +950,14 @@
       
   257  probably better off using connection.escape(o) instead, since\n\
       
   258  it will escape entire sequences as well as strings.";
       
   259  
       
   260 -static PyObject *
       
   261 -_mysql_escape_string(
       
   262 -	_mysql_ConnectionObject *self,
       
   263 -	PyObject *args)
       
   264 +static PyObject *_mysql_ConnectionObject_escape_string(	_mysql_ConnectionObject *self,	PyObject *args)
       
   265  {
       
   266  	PyObject *str;
       
   267  	char *in, *out;
       
   268  	int len, size;
       
   269  	if (!PyArg_ParseTuple(args, "s#:escape_string", &in, &size)) return NULL;
       
   270 -	str = PyString_FromStringAndSize((char *) NULL, size*2+1);
       
   271 -	if (!str) return PyErr_NoMemory();
       
   272 -	out = PyString_AS_STRING(str);
       
   273 +	out = PyMem_New(char, size*2+1);
       
   274 +	if (!out) return PyErr_NoMemory();
       
   275  #if MYSQL_VERSION_ID < 32321
       
   276  	len = mysql_escape_string(out, in, size);
       
   277  #else
       
   278 @@ -987,10 +967,16 @@
       
   279  	else
       
   280  		len = mysql_escape_string(out, in, size);
       
   281  #endif
       
   282 -	if (_PyString_Resize(&str, len) < 0) return NULL;
       
   283 +	str = PyUnicode_FromString(out);
       
   284 +	PyMem_Del(out);
       
   285  	return (str);
       
   286  }
       
   287  
       
   288 +static PyObject *_mysql_escape_string( PyObject *self, PyObject *args)
       
   289 +{
       
   290 +	return _mysql_ConnectionObject_escape_string(NULL, args);
       
   291 +}
       
   292 +
       
   293  static char _mysql_string_literal__doc__[] =
       
   294  "string_literal(obj) -- converts object obj into a SQL string literal.\n\
       
   295  This means, any special SQL characters are escaped, and it is enclosed\n\
       
   296 @@ -1001,43 +987,50 @@
       
   297  Use connection.string_literal(obj), if you use it at all.\n\
       
   298  _mysql.string_literal(obj) cannot handle character sets.";
       
   299  
       
   300 -static PyObject *
       
   301 -_mysql_string_literal(
       
   302 -	_mysql_ConnectionObject *self,
       
   303 -	PyObject *args)
       
   304 +static PyObject *_mysql_ConnectionObject_string_literal(_mysql_ConnectionObject *self, PyObject *args)
       
   305  {
       
   306 -	PyObject *str, *s, *o, *d;
       
   307 +	PyObject *str, *s, *s2, *o, *d;
       
   308  	char *in, *out;
       
   309  	int len, size;
       
   310  	if (!PyArg_ParseTuple(args, "O|O:string_literal", &o, &d)) return NULL;
       
   311  	s = PyObject_Str(o);
       
   312  	if (!s) return NULL;
       
   313 -	in = PyString_AsString(s);
       
   314 -	size = PyString_GET_SIZE(s);
       
   315 -	str = PyString_FromStringAndSize((char *) NULL, size*2+3);
       
   316 -	if (!str) return PyErr_NoMemory();
       
   317 -	out = PyString_AS_STRING(str);
       
   318 +	s2 = PyUnicode_AsUTF8String(s);
       
   319 +	if (!s2) return NULL;
       
   320 +	in = PyBytes_AsString(s2);
       
   321 +	if (!in) return NULL;
       
   322 +	size = PyBytes_GET_SIZE(s2);
       
   323 +	out = PyMem_New(char, size*2+3);
       
   324 +	if (!out) return PyErr_NoMemory();
       
   325  #if MYSQL_VERSION_ID < 32321
       
   326  	len = mysql_escape_string(out+1, in, size);
       
   327  #else
       
   328  	check_server_init(NULL);
       
   329 -	if (self && self->open)
       
   330 +	if (self && self->open )
       
   331 +	{
       
   332  		len = mysql_real_escape_string(&(self->connection), out+1, in, size);
       
   333 -	else
       
   334 +	} else
       
   335 +	{
       
   336  		len = mysql_escape_string(out+1, in, size);
       
   337 +	};
       
   338  #endif
       
   339  	*out = *(out+len+1) = '\'';
       
   340 -	if (_PyString_Resize(&str, len+2) < 0) return NULL;
       
   341 +	*(out+len+2) = '\0';
       
   342 +	str = PyUnicode_FromString(out);
       
   343 +	PyMem_Del(out);
       
   344 +	Py_DECREF(s2);
       
   345  	Py_DECREF(s);
       
   346  	return (str);
       
   347  }
       
   348  
       
   349 +static PyObject *_mysql_string_literal(PyObject *self, PyObject *args)
       
   350 +{
       
   351 +	return _mysql_ConnectionObject_string_literal(NULL, args);
       
   352 +}
       
   353 +
       
   354  static PyObject *_mysql_NULL;
       
   355  
       
   356 -static PyObject *
       
   357 -_escape_item(
       
   358 -	PyObject *item,
       
   359 -	PyObject *d)
       
   360 +static PyObject *_escape_item( PyObject *item, PyObject *d)
       
   361  {
       
   362  	PyObject *quoted=NULL, *itemtype, *itemconv;
       
   363  	if (!(itemtype = PyObject_Type(item)))
       
   364 @@ -1047,11 +1040,11 @@
       
   365  	if (!itemconv) {
       
   366  		PyErr_Clear();
       
   367  		itemconv = PyObject_GetItem(d,
       
   368 -				 (PyObject *) &PyString_Type);
       
   369 +			(PyObject *) &PyUnicode_Type);
       
   370  	}
       
   371  	if (!itemconv) {
       
   372  		PyErr_SetString(PyExc_TypeError,
       
   373 -				"no default type converter defined");
       
   374 +			"no default type converter defined");
       
   375  		goto error;
       
   376  	}
       
   377  	quoted = PyObject_CallFunction(itemconv, "OO", item, d);
       
   378 @@ -1064,32 +1057,33 @@
       
   379  "escape(obj, dict) -- escape any special characters in object obj\n\
       
   380  using mapping dict to provide quoting functions for each type.\n\
       
   381  Returns a SQL literal string.";
       
   382 -static PyObject *
       
   383 -_mysql_escape(
       
   384 -	PyObject *self,
       
   385 -	PyObject *args)
       
   386 +static PyObject *_mysql_ConnectionObject_escape( _mysql_ConnectionObject *self, PyObject *args)
       
   387  {
       
   388  	PyObject *o=NULL, *d=NULL;
       
   389  	if (!PyArg_ParseTuple(args, "O|O:escape", &o, &d))
       
   390  		return NULL;
       
   391  	if (d) {
       
   392  		if (!PyMapping_Check(d)) {
       
   393 -			PyErr_SetString(PyExc_TypeError,
       
   394 -					"argument 2 must be a mapping");
       
   395 +			PyErr_SetString(PyExc_TypeError, "argument 2 must be a mapping");
       
   396  			return NULL;
       
   397  		}
       
   398  		return _escape_item(o, d);
       
   399 -	} else {
       
   400 -		if (!self) {
       
   401 -			PyErr_SetString(PyExc_TypeError,
       
   402 -					"argument 2 must be a mapping");
       
   403 +	} else
       
   404 +	{
       
   405 +		if (!self)
       
   406 +		{
       
   407 +			PyErr_SetString(PyExc_TypeError, "argument 2 must be a mapping");
       
   408  			return NULL;
       
   409  		}
       
   410 -		return _escape_item(o,
       
   411 -			   ((_mysql_ConnectionObject *) self)->converter);
       
   412 +		return _escape_item(o, self->converter);
       
   413  	}
       
   414  }
       
   415  
       
   416 +static PyObject *_mysql_escape(	PyObject *self,	PyObject *args)
       
   417 +{
       
   418 +	return _mysql_ConnectionObject_escape(NULL, args);
       
   419 +}
       
   420 +
       
   421  static char _mysql_escape_sequence__doc__[] =
       
   422  "escape_sequence(seq, dict) -- escape any special characters in sequence\n\
       
   423  seq using mapping dict to provide quoting functions for each type.\n\
       
   424 @@ -1160,20 +1154,28 @@
       
   425  the Cursor.description attribute.\n\
       
   426  ";
       
   427  
       
   428 -static PyObject *
       
   429 -_mysql_ResultObject_describe(
       
   430 -	_mysql_ResultObject *self,
       
   431 -	PyObject *args)
       
   432 +static PyObject * _mysql_ResultObject_describe ( _mysql_ResultObject *self, PyObject *args)
       
   433  {
       
   434 -	PyObject *d;
       
   435 +	PyObject *d = NULL;
       
   436  	MYSQL_FIELD *fields;
       
   437  	unsigned int i, n;
       
   438 -	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   439 +	
       
   440 +	if ( !PyArg_ParseTuple(args, ""))
       
   441 +	{
       
   442 +		return NULL;
       
   443 +	};
       
   444 +
       
   445  	check_result_connection(self);
       
   446 +
       
   447  	n = mysql_num_fields(self->result);
       
   448  	fields = mysql_fetch_fields(self->result);
       
   449 -	if (!(d = PyTuple_New(n))) return NULL;
       
   450 -	for (i=0; i<n; i++) {
       
   451 +	d = PyTuple_New(n);
       
   452 +	if ( d == NULL )
       
   453 +	{
       
   454 +		return NULL;
       
   455 +	};
       
   456 +	for (i = 0; i < n; i++)
       
   457 +	{
       
   458  		PyObject *t;
       
   459  		t = Py_BuildValue("(siiiiii)",
       
   460  				  fields[i].name,
       
   461 @@ -1183,13 +1185,16 @@
       
   462  				  (long) fields[i].length,
       
   463  				  (long) fields[i].decimals,
       
   464  				  (long) !(IS_NOT_NULL(fields[i].flags)));
       
   465 -		if (!t) goto error;
       
   466 +		if (t == NULL)
       
   467 +		{
       
   468 +			Py_XDECREF(d);
       
   469 +			d = NULL;
       
   470 +			break;
       
   471 +		};
       
   472  		PyTuple_SET_ITEM(d, i, t);
       
   473 -	}
       
   474 +	};
       
   475 +	
       
   476  	return d;
       
   477 -  error:
       
   478 -	Py_XDECREF(d);
       
   479 -	return NULL;
       
   480  }
       
   481  	
       
   482  static char _mysql_ResultObject_field_flags__doc__[] =
       
   483 @@ -1211,7 +1216,7 @@
       
   484  	if (!(d = PyTuple_New(n))) return NULL;
       
   485  	for (i=0; i<n; i++) {
       
   486  		PyObject *f;
       
   487 -		if (!(f = PyInt_FromLong((long)fields[i].flags))) goto error;
       
   488 +		if (!(f = PyLong_FromLong((long)fields[i].flags))) goto error;
       
   489  		PyTuple_SET_ITEM(d, i, f);
       
   490  	}
       
   491  	return d;
       
   492 @@ -1221,27 +1226,44 @@
       
   493  }
       
   494  
       
   495  static PyObject *
       
   496 -_mysql_field_to_python(
       
   497 -	PyObject *converter,
       
   498 -	char *rowitem,
       
   499 -	unsigned long length)
       
   500 +_mysql_field_to_python(PyObject *converter, char *rowitem, unsigned long length, const char *charset)
       
   501  {
       
   502  	PyObject *v;
       
   503 -	if (rowitem) {
       
   504 -		if (converter != Py_None)
       
   505 -			v = PyObject_CallFunction(converter,
       
   506 -						  "s#",
       
   507 -						  rowitem,
       
   508 -						  (int)length);
       
   509 -		else
       
   510 -			v = PyString_FromStringAndSize(rowitem,
       
   511 -						       (int)length);
       
   512 -		if (!v)
       
   513 -			return NULL;
       
   514 -	} else {
       
   515 +	if (rowitem)
       
   516 +	{
       
   517 +		if (charset)
       
   518 +		{
       
   519 +			PyObject *rowitem_unicode = PyUnicode_Decode(rowitem, (int)length, charset, "replace");
       
   520 +			if (rowitem_unicode == NULL)
       
   521 +			{
       
   522 +				return NULL;
       
   523 +			} else
       
   524 +			{
       
   525 +				if (converter != Py_None)
       
   526 +		        {
       
   527 +					v = PyObject_CallFunction(converter, "O", rowitem_unicode);
       
   528 +			                Py_XDECREF(rowitem_unicode);
       
   529 +		        } else
       
   530 +				{
       
   531 +					v = rowitem_unicode;
       
   532 +				};
       
   533 +			};
       
   534 +		} else
       
   535 +		{
       
   536 +			if (converter != Py_None)
       
   537 +		    {
       
   538 +				v = PyObject_CallFunction(converter, "s#", rowitem, (int)length);
       
   539 +		    } else
       
   540 +		    {
       
   541 +				v = PyUnicode_FromStringAndSize(rowitem, (int)length);
       
   542 +			    if (!v) return NULL;
       
   543 +			};
       
   544 +		};
       
   545 +	} else
       
   546 +	{
       
   547  		Py_INCREF(Py_None);
       
   548  		v = Py_None;
       
   549 -	}
       
   550 +	};
       
   551  	return v;
       
   552  }
       
   553  
       
   554 @@ -1253,14 +1275,22 @@
       
   555  	unsigned int n, i;
       
   556  	unsigned long *length;
       
   557  	PyObject *r, *c;
       
   558 +	const char *charset;
       
   559  
       
   560  	n = mysql_num_fields(self->result);
       
   561  	if (!(r = PyTuple_New(n))) return NULL;
       
   562  	length = mysql_fetch_lengths(self->result);
       
   563 +
       
   564 +#if MYSQL_VERSION_ID >= 32321
       
   565 +	charset = mysql_character_set_name(&(self->conn->connection));
       
   566 +#else
       
   567 +	charset = "latin1";
       
   568 +#endif
       
   569 +
       
   570  	for (i=0; i<n; i++) {
       
   571  		PyObject *v;
       
   572  		c = PyTuple_GET_ITEM(self->converter, i);
       
   573 -		v = _mysql_field_to_python(c, row[i], length[i]);
       
   574 +		v = _mysql_field_to_python(c, row[i], length[i], charset);
       
   575  		if (!v) goto error;
       
   576  		PyTuple_SET_ITEM(r, i, v);
       
   577  	}
       
   578 @@ -1278,16 +1308,24 @@
       
   579  	unsigned int n, i;
       
   580  	unsigned long *length;
       
   581  	PyObject *r, *c;
       
   582 -        MYSQL_FIELD *fields;
       
   583 +    MYSQL_FIELD *fields;
       
   584 +	const char *charset;
       
   585  
       
   586  	n = mysql_num_fields(self->result);
       
   587  	if (!(r = PyDict_New())) return NULL;
       
   588  	length = mysql_fetch_lengths(self->result);
       
   589          fields = mysql_fetch_fields(self->result);
       
   590 +
       
   591 +#if MYSQL_VERSION_ID >= 32321
       
   592 +	charset = mysql_character_set_name(&(self->conn->connection));
       
   593 +#else
       
   594 +	charset = "latin1";
       
   595 +#endif
       
   596 +
       
   597  	for (i=0; i<n; i++) {
       
   598  		PyObject *v;
       
   599  		c = PyTuple_GET_ITEM(self->converter, i);
       
   600 -		v = _mysql_field_to_python(c, row[i], length[i]);
       
   601 +		v = _mysql_field_to_python(c, row[i], length[i], charset);
       
   602  		if (!v) goto error;
       
   603  		if (!PyMapping_HasKeyString(r, fields[i].name)) {
       
   604  			PyMapping_SetItemString(r, fields[i].name, v);
       
   605 @@ -1317,16 +1355,24 @@
       
   606  	unsigned int n, i;
       
   607  	unsigned long *length;
       
   608  	PyObject *r, *c;
       
   609 -        MYSQL_FIELD *fields;
       
   610 +    MYSQL_FIELD *fields;
       
   611 +	const char *charset;
       
   612  
       
   613  	n = mysql_num_fields(self->result);
       
   614  	if (!(r = PyDict_New())) return NULL;
       
   615  	length = mysql_fetch_lengths(self->result);
       
   616          fields = mysql_fetch_fields(self->result);
       
   617 +
       
   618 +#if MYSQL_VERSION_ID >= 32321
       
   619 +	charset = mysql_character_set_name(&(self->conn->connection));
       
   620 +#else
       
   621 +	charset = "latin1";
       
   622 +#endif
       
   623 +
       
   624  	for (i=0; i<n; i++) {
       
   625  		PyObject *v;
       
   626  		c = PyTuple_GET_ITEM(self->converter, i);
       
   627 -		v = _mysql_field_to_python(c, row[i], length[i]);
       
   628 +		v = _mysql_field_to_python(c, row[i], length[i], charset);
       
   629  		if (!v) goto error;
       
   630  		{
       
   631  			int len=0;
       
   632 @@ -1354,8 +1400,8 @@
       
   633  _mysql__fetch_row(
       
   634  	_mysql_ResultObject *self,
       
   635  	PyObject **r,
       
   636 -	int skiprows,
       
   637 -	int maxrows,
       
   638 +	unsigned int skiprows,
       
   639 +	unsigned int maxrows,
       
   640  	_PYFUNC *convert_row)
       
   641  {
       
   642  	unsigned int i;
       
   643 @@ -1516,7 +1562,7 @@
       
   644  #else
       
   645  	s = "latin1";
       
   646  #endif
       
   647 -	return PyString_FromString(s);
       
   648 +	return PyUnicode_FromString(s);
       
   649  }
       
   650  
       
   651  #if MYSQL_VERSION_ID >= 50007
       
   652 @@ -1578,15 +1624,15 @@
       
   653  	mysql_get_character_set_info(&(self->connection), &cs);
       
   654  	if (!(result = PyDict_New())) return NULL;
       
   655  	if (cs.csname)
       
   656 -		PyDict_SetItemString(result, "name", PyString_FromString(cs.csname));
       
   657 +		PyDict_SetItemString(result, "name", PyUnicode_FromString(cs.csname));
       
   658  	if (cs.name)
       
   659 -		PyDict_SetItemString(result, "collation", PyString_FromString(cs.name));
       
   660 +		PyDict_SetItemString(result, "collation", PyUnicode_FromString(cs.name));
       
   661  	if (cs.comment)
       
   662 -		PyDict_SetItemString(result, "comment", PyString_FromString(cs.comment));
       
   663 +		PyDict_SetItemString(result, "comment", PyUnicode_FromString(cs.comment));
       
   664  	if (cs.dir)
       
   665 -		PyDict_SetItemString(result, "dir", PyString_FromString(cs.dir));
       
   666 -	PyDict_SetItemString(result, "mbminlen", PyInt_FromLong(cs.mbminlen));
       
   667 -	PyDict_SetItemString(result, "mbmaxlen", PyInt_FromLong(cs.mbmaxlen));
       
   668 +		PyDict_SetItemString(result, "dir", PyUnicode_FromString(cs.dir));
       
   669 +	PyDict_SetItemString(result, "mbminlen", PyLong_FromLong(cs.mbminlen));
       
   670 +	PyDict_SetItemString(result, "mbmaxlen", PyLong_FromLong(cs.mbmaxlen));
       
   671  	return result;
       
   672  }
       
   673  #endif
       
   674 @@ -1596,12 +1642,12 @@
       
   675  the client library version.";
       
   676  static PyObject *
       
   677  _mysql_get_client_info(
       
   678 -	PyObject *self,
       
   679 -	PyObject *args)
       
   680 +					   PyObject *self,
       
   681 +					   PyObject *args)
       
   682  {
       
   683  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   684  	check_server_init(NULL);
       
   685 -	return PyString_FromString(mysql_get_client_info());
       
   686 +	return PyUnicode_FromString(mysql_get_client_info());
       
   687  }
       
   688  
       
   689  static char _mysql_ConnectionObject_get_host_info__doc__[] =
       
   690 @@ -1616,7 +1662,7 @@
       
   691  {
       
   692  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   693  	check_connection(self);
       
   694 -	return PyString_FromString(mysql_get_host_info(&(self->connection)));
       
   695 +	return PyUnicode_FromString(mysql_get_host_info(&(self->connection)));
       
   696  }
       
   697  
       
   698  static char _mysql_ConnectionObject_get_proto_info__doc__[] =
       
   699 @@ -1631,7 +1677,7 @@
       
   700  {
       
   701  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   702  	check_connection(self);
       
   703 -	return PyInt_FromLong((long)mysql_get_proto_info(&(self->connection)));
       
   704 +	return PyLong_FromLong((long)mysql_get_proto_info(&(self->connection)));
       
   705  }
       
   706  
       
   707  static char _mysql_ConnectionObject_get_server_info__doc__[] =
       
   708 @@ -1646,7 +1692,7 @@
       
   709  {
       
   710  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   711  	check_connection(self);
       
   712 -	return PyString_FromString(mysql_get_server_info(&(self->connection)));
       
   713 +	return PyUnicode_FromString(mysql_get_server_info(&(self->connection)));
       
   714  }
       
   715  
       
   716  static char _mysql_ConnectionObject_info__doc__[] =
       
   717 @@ -1664,7 +1710,7 @@
       
   718  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   719  	check_connection(self);
       
   720  	s = mysql_info(&(self->connection));
       
   721 -	if (s) return PyString_FromString(s);
       
   722 +	if (s) return PyUnicode_FromString(s);
       
   723  	Py_INCREF(Py_None);
       
   724  	return Py_None;
       
   725  }
       
   726 @@ -1739,9 +1785,9 @@
       
   727  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   728  	check_connection(self);
       
   729  #if MYSQL_VERSION_ID < 32224
       
   730 -	return PyInt_FromLong((long)mysql_num_fields(&(self->connection)));
       
   731 +	return PyNumber_FromLong((long)mysql_num_fields(&(self->connection)));
       
   732  #else
       
   733 -	return PyInt_FromLong((long)mysql_field_count(&(self->connection)));
       
   734 +	return PyLong_FromLong((long)mysql_field_count(&(self->connection)));
       
   735  #endif
       
   736  }	
       
   737  
       
   738 @@ -1755,7 +1801,7 @@
       
   739  {
       
   740  	if (!PyArg_ParseTuple(args, "")) return NULL;
       
   741  	check_result_connection(self);
       
   742 -	return PyInt_FromLong((long)mysql_num_fields(self->result));
       
   743 +	return PyLong_FromLong((long)mysql_num_fields(self->result));
       
   744  }	
       
   745  
       
   746  static char _mysql_ResultObject_num_rows__doc__[] =
       
   747 @@ -1907,7 +1953,7 @@
       
   748  	s = mysql_stat(&(self->connection));
       
   749  	Py_END_ALLOW_THREADS
       
   750  	if (!s) return _mysql_Exception(self);
       
   751 -	return PyString_FromString(s);
       
   752 +	return PyUnicode_FromString(s);
       
   753  }
       
   754  
       
   755  static char _mysql_ConnectionObject_store_result__doc__[] =
       
   756 @@ -1968,7 +2014,7 @@
       
   757  	Py_BEGIN_ALLOW_THREADS
       
   758  	pid = mysql_thread_id(&(self->connection));
       
   759  	Py_END_ALLOW_THREADS
       
   760 -	return PyInt_FromLong((long)pid);
       
   761 +	return PyLong_FromLong((long)pid);
       
   762  }
       
   763  
       
   764  static char _mysql_ConnectionObject_use_result__doc__[] =
       
   765 @@ -2033,7 +2079,7 @@
       
   766  	else
       
   767  		sprintf(buf, "<_mysql.connection closed at %lx>",
       
   768  			(long)self);
       
   769 -	return PyString_FromString(buf);
       
   770 +	return PyUnicode_FromString(buf);
       
   771  }
       
   772  
       
   773  static char _mysql_ResultObject_data_seek__doc__[] =
       
   774 @@ -2089,7 +2135,7 @@
       
   775  		return NULL;
       
   776  	}
       
   777  	r = mysql_row_tell(self->result);
       
   778 -	return PyInt_FromLong(r-self->result->data->data);
       
   779 +	return PyLong_FromLong(r-self->result->data->data);
       
   780  }
       
   781  
       
   782  static void
       
   783 @@ -2109,7 +2155,7 @@
       
   784  	char buf[300];
       
   785  	sprintf(buf, "<_mysql.result object at %lx>",
       
   786  		(long)self);
       
   787 -	return PyString_FromString(buf);
       
   788 +	return PyUnicode_FromString(buf);
       
   789  }
       
   790  
       
   791  static PyMethodDef _mysql_ConnectionObject_methods[] = {
       
   792 @@ -2207,13 +2253,13 @@
       
   793  	},
       
   794  	{
       
   795  		"escape",
       
   796 -		(PyCFunction)_mysql_escape,
       
   797 +		(PyCFunction)_mysql_ConnectionObject_escape,
       
   798  		METH_VARARGS,
       
   799  		_mysql_escape__doc__
       
   800  	},
       
   801  	{
       
   802  		"escape_string",
       
   803 -		(PyCFunction)_mysql_escape_string,
       
   804 +		(PyCFunction)_mysql_ConnectionObject_escape_string,
       
   805  		METH_VARARGS,
       
   806  		_mysql_escape_string__doc__
       
   807  	},
       
   808 @@ -2309,7 +2355,7 @@
       
   809  	},
       
   810  	{
       
   811  		"string_literal",
       
   812 -		(PyCFunction)_mysql_string_literal,
       
   813 +		(PyCFunction)_mysql_ConnectionObject_string_literal,
       
   814  		METH_VARARGS,
       
   815  		_mysql_string_literal__doc__},
       
   816  	{
       
   817 @@ -2332,7 +2378,7 @@
       
   818  		"open",
       
   819  		T_INT,
       
   820  		offsetof(_mysql_ConnectionObject,open),
       
   821 -		RO,
       
   822 +		READONLY,
       
   823  		"True if connection is open"
       
   824  		),
       
   825  	MyMember(
       
   826 @@ -2346,20 +2392,20 @@
       
   827  		"server_capabilities",
       
   828  		T_UINT,
       
   829  		offsetof(_mysql_ConnectionObject,connection.server_capabilities),
       
   830 -		RO,
       
   831 +		READONLY,
       
   832  		"Capabilites of server; consult MySQLdb.constants.CLIENT"
       
   833  		),
       
   834  	MyMember(
       
   835  		 "port",
       
   836  		 T_UINT,
       
   837  		 offsetof(_mysql_ConnectionObject,connection.port),
       
   838 -		 RO,
       
   839 +		 READONLY,
       
   840  		 "TCP/IP port of the server connection"
       
   841  		 ),
       
   842  	MyMember(
       
   843  		 "client_flag",
       
   844  		 T_UINT,
       
   845 -		 RO,
       
   846 +		 READONLY,
       
   847  		 offsetof(_mysql_ConnectionObject,connection.client_flag),
       
   848  		 "Client flags; refer to MySQLdb.constants.CLIENT"
       
   849  		 ),
       
   850 @@ -2423,127 +2469,22 @@
       
   851  		"converter",
       
   852  		T_OBJECT,
       
   853  		offsetof(_mysql_ResultObject,converter),
       
   854 -		RO,
       
   855 +		READONLY,
       
   856  		"Type conversion mapping"
       
   857  		),
       
   858  	{NULL} /* Sentinel */
       
   859  };
       
   860 -                                                                        
       
   861 -static PyObject *
       
   862 -_mysql_ConnectionObject_getattr(
       
   863 -	_mysql_ConnectionObject *self,
       
   864 -	char *name)
       
   865 -{
       
   866 -	PyObject *res;
       
   867 -
       
   868 -	res = Py_FindMethod(_mysql_ConnectionObject_methods, (PyObject *)self, name);
       
   869 -	if (res != NULL)
       
   870 -		return res;
       
   871 -	PyErr_Clear();
       
   872 -	if (strcmp(name, "closed") == 0)
       
   873 -		return PyInt_FromLong((long)!(self->open));
       
   874 -#if PY_VERSION_HEX < 0x02020000
       
   875 -	return PyMember_Get((char *)self, _mysql_ConnectionObject_memberlist, name);
       
   876 -#else
       
   877 -	{
       
   878 -		MyMemberlist(*l);
       
   879 -		for (l = _mysql_ConnectionObject_memberlist; l->name != NULL; l++) {
       
   880 -			if (strcmp(l->name, name) == 0)
       
   881 -				return PyMember_GetOne((char *)self, l);
       
   882 -		}
       
   883 -		PyErr_SetString(PyExc_AttributeError, name);
       
   884 -		return NULL;
       
   885 -	}
       
   886 -#endif
       
   887 -}
       
   888 -
       
   889 -static PyObject *
       
   890 -_mysql_ResultObject_getattr(
       
   891 -	_mysql_ResultObject *self,
       
   892 -	char *name)
       
   893 -{
       
   894 -	PyObject *res;
       
   895 -
       
   896 -	res = Py_FindMethod(_mysql_ResultObject_methods, (PyObject *)self, name);
       
   897 -	if (res != NULL)
       
   898 -		return res;
       
   899 -	PyErr_Clear();
       
   900 -#if PY_VERSION_HEX < 0x02020000
       
   901 -	return PyMember_Get((char *)self, _mysql_ResultObject_memberlist, name);
       
   902 -#else
       
   903 -	{
       
   904 -		MyMemberlist(*l);
       
   905 -		for (l = _mysql_ResultObject_memberlist; l->name != NULL; l++) {
       
   906 -			if (strcmp(l->name, name) == 0)
       
   907 -				return PyMember_GetOne((char *)self, l);
       
   908 -		}
       
   909 -		PyErr_SetString(PyExc_AttributeError, name);
       
   910 -		return NULL;
       
   911 -	}
       
   912 -#endif
       
   913 -}
       
   914 -
       
   915 -static int
       
   916 -_mysql_ConnectionObject_setattr(
       
   917 -	_mysql_ConnectionObject *self,
       
   918 -	char *name,
       
   919 -	PyObject *v)
       
   920 -{
       
   921 -	if (v == NULL) {
       
   922 -		PyErr_SetString(PyExc_AttributeError,
       
   923 -				"can't delete connection attributes");
       
   924 -		return -1;
       
   925 -	}
       
   926 -#if PY_VERSION_HEX < 0x02020000
       
   927 -	return PyMember_Set((char *)self, _mysql_ConnectionObject_memberlist, name, v);
       
   928 -#else
       
   929 -        {
       
   930 -		MyMemberlist(*l);
       
   931 -		for (l = _mysql_ConnectionObject_memberlist; l->name != NULL; l++)
       
   932 -			if (strcmp(l->name, name) == 0)
       
   933 -				return PyMember_SetOne((char *)self, l, v);
       
   934 -	}
       
   935 -        PyErr_SetString(PyExc_AttributeError, name);
       
   936 -        return -1;
       
   937 -#endif
       
   938 -}
       
   939 -
       
   940 -static int
       
   941 -_mysql_ResultObject_setattr(
       
   942 -	_mysql_ResultObject *self,
       
   943 -	char *name,
       
   944 -	PyObject *v)
       
   945 -{
       
   946 -	if (v == NULL) {
       
   947 -		PyErr_SetString(PyExc_AttributeError,
       
   948 -				"can't delete connection attributes");
       
   949 -		return -1;
       
   950 -	}
       
   951 -#if PY_VERSION_HEX < 0x02020000
       
   952 -	return PyMember_Set((char *)self, _mysql_ResultObject_memberlist, name, v);
       
   953 -#else
       
   954 -        {
       
   955 -		MyMemberlist(*l);
       
   956 -		for (l = _mysql_ResultObject_memberlist; l->name != NULL; l++)
       
   957 -			if (strcmp(l->name, name) == 0)
       
   958 -				return PyMember_SetOne((char *)self, l, v);
       
   959 -	}
       
   960 -        PyErr_SetString(PyExc_AttributeError, name);
       
   961 -        return -1;
       
   962 -#endif
       
   963 -}
       
   964  
       
   965  PyTypeObject _mysql_ConnectionObject_Type = {
       
   966 -	PyObject_HEAD_INIT(NULL)
       
   967 -	0,
       
   968 +	PyVarObject_HEAD_INIT(NULL, 0)
       
   969  	"_mysql.connection", /* (char *)tp_name For printing */
       
   970  	sizeof(_mysql_ConnectionObject),
       
   971  	0,
       
   972  	(destructor)_mysql_ConnectionObject_dealloc, /* tp_dealloc */
       
   973 -	0, /*tp_print*/
       
   974 -	(getattrfunc)_mysql_ConnectionObject_getattr, /* tp_getattr */
       
   975 -	(setattrfunc)_mysql_ConnectionObject_setattr, /* tp_setattr */
       
   976 -	0, /*tp_compare*/
       
   977 +	0, /* tp_print*/
       
   978 +	0, /* tp_getattr */
       
   979 +	0, /* tp_setattr */
       
   980 +	0, /* tp_compare*/
       
   981  	(reprfunc)_mysql_ConnectionObject_repr, /* tp_repr */
       
   982  	
       
   983  	/* Method suites for standard classes */
       
   984 @@ -2564,33 +2505,20 @@
       
   985  	0, /* (PyBufferProcs *) tp_as_buffer */
       
   986  	
       
   987  	/* Flags to define presence of optional/expanded features */
       
   988 -#if PY_VERSION_HEX < 0x02020000
       
   989 -	Py_TPFLAGS_DEFAULT, /* (long) tp_flags */
       
   990 -#else
       
   991  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
       
   992 -#endif
       
   993  	_mysql_connect__doc__, /* (char *) tp_doc Documentation string */
       
   994 -#if PY_VERSION_HEX >= 0x02000000	
       
   995  	/* Assigned meaning in release 2.0 */
       
   996 -#if PY_VERSION_HEX >= 0x02020000
       
   997  	/* call function for all accessible objects */
       
   998  	(traverseproc) _mysql_ConnectionObject_traverse, /* tp_traverse */
       
   999  	
       
  1000  	/* delete references to contained objects */
       
  1001  	(inquiry) _mysql_ConnectionObject_clear, /* tp_clear */
       
  1002 -#else
       
  1003 -	/* not supporting pre-2.2 GC */
       
  1004 -	0,
       
  1005 -	0,
       
  1006 -#endif
       
  1007 -#if PY_VERSION_HEX >= 0x02010000	
       
  1008  	/* Assigned meaning in release 2.1 */
       
  1009  	/* rich comparisons */
       
  1010  	0, /* (richcmpfunc) tp_richcompare */
       
  1011  	
       
  1012  	/* weak reference enabler */
       
  1013  	0, /* (long) tp_weaklistoffset */
       
  1014 -#if PY_VERSION_HEX >= 0x02020000
       
  1015  	/* Added in release 2.2 */
       
  1016  	/* Iterators */
       
  1017  	0, /* (getiterfunc) tp_iter */
       
  1018 @@ -2612,22 +2540,18 @@
       
  1019  	0, /* (PyObject *) tp_bases */
       
  1020  	0, /* (PyObject *) tp_mro method resolution order */
       
  1021  	0, /* (PyObject *) tp_defined */
       
  1022 -#endif /* python 2.2 */
       
  1023 -#endif /* python 2.1 */
       
  1024 -#endif /* python 2.0 */
       
  1025  } ;
       
  1026  
       
  1027  PyTypeObject _mysql_ResultObject_Type = {
       
  1028 -	PyObject_HEAD_INIT(NULL)
       
  1029 -	0,
       
  1030 +	 PyVarObject_HEAD_INIT(NULL, 0)
       
  1031  	"_mysql.result",
       
  1032  	sizeof(_mysql_ResultObject),
       
  1033  	0,
       
  1034  	(destructor)_mysql_ResultObject_dealloc, /* tp_dealloc */
       
  1035 -	0, /*tp_print*/
       
  1036 -	(getattrfunc)_mysql_ResultObject_getattr, /* tp_getattr */
       
  1037 -	(setattrfunc)_mysql_ResultObject_setattr, /* tp_setattr */
       
  1038 -	0, /*tp_compare*/
       
  1039 +	0, /* tp_print */
       
  1040 +	0, /* tp_getattr */
       
  1041 +	0, /* tp_setattr */
       
  1042 +	0, /* tp_compare */
       
  1043  	(reprfunc)_mysql_ResultObject_repr, /* tp_repr */
       
  1044  	
       
  1045  	/* Method suites for standard classes */
       
  1046 @@ -2648,34 +2572,20 @@
       
  1047  	0, /* (PyBufferProcs *) tp_as_buffer */
       
  1048  	
       
  1049  	/* Flags to define presence of optional/expanded features */
       
  1050 -#if PY_VERSION_HEX < 0x02020000
       
  1051 -	Py_TPFLAGS_DEFAULT, /* (long) tp_flags */
       
  1052 -#else
       
  1053  	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
       
  1054 -#endif
       
  1055 -	
       
  1056  	_mysql_ResultObject__doc__, /* (char *) tp_doc Documentation string */
       
  1057 -#if PY_VERSION_HEX >= 0x02000000	
       
  1058  	/* Assigned meaning in release 2.0 */
       
  1059 -#if PY_VERSION_HEX >= 0x02020000
       
  1060  	/* call function for all accessible objects */
       
  1061  	(traverseproc) _mysql_ResultObject_traverse, /* tp_traverse */
       
  1062  	
       
  1063  	/* delete references to contained objects */
       
  1064  	(inquiry) _mysql_ResultObject_clear, /* tp_clear */
       
  1065 -#else
       
  1066 -	/* not supporting pre-2.2 GC */
       
  1067 -	0,
       
  1068 -	0,
       
  1069 -#endif
       
  1070 -#if PY_VERSION_HEX >= 0x02010000	
       
  1071  	/* Assigned meaning in release 2.1 */
       
  1072  	/* rich comparisons */
       
  1073  	0, /* (richcmpfunc) tp_richcompare */
       
  1074  	
       
  1075  	/* weak reference enabler */
       
  1076  	0, /* (long) tp_weaklistoffset */
       
  1077 -#if PY_VERSION_HEX >= 0x02020000
       
  1078  	/* Added in release 2.2 */
       
  1079  	/* Iterators */
       
  1080  	0, /* (getiterfunc) tp_iter */
       
  1081 @@ -2697,13 +2607,9 @@
       
  1082  	0, /* (PyObject *) tp_bases */
       
  1083  	0, /* (PyObject *) tp_mro method resolution order */
       
  1084  	0, /* (PyObject *) tp_defined */
       
  1085 -#endif /* python 2.2 */
       
  1086 -#endif /* python 2.1 */
       
  1087 -#endif /* python 2.0 */
       
  1088  };
       
  1089  
       
  1090 -static PyMethodDef
       
  1091 -_mysql_methods[] = {
       
  1092 +static PyMethodDef _mysql_methods[] = {
       
  1093  	{ 
       
  1094  		"connect",
       
  1095  		(PyCFunction)_mysql_connect,
       
  1096 @@ -2775,16 +2681,11 @@
       
  1097  	{NULL, NULL} /* sentinel */
       
  1098  };
       
  1099  
       
  1100 -static PyObject *
       
  1101 -_mysql_NewException(
       
  1102 -	PyObject *dict,
       
  1103 -	PyObject *edict,
       
  1104 -	char *name)
       
  1105 +static PyObject *_mysql_NewException( PyObject *dict, PyObject *edict, char *name)
       
  1106  {
       
  1107  	PyObject *e;
       
  1108  
       
  1109 -	if (!(e = PyDict_GetItemString(edict, name)))
       
  1110 -		return NULL;
       
  1111 +	if (!(e = PyDict_GetItemString(edict, name))) return NULL;
       
  1112  	if (PyDict_SetItemString(dict, name, e)) return NULL;
       
  1113  	return e;
       
  1114  }
       
  1115 @@ -2806,85 +2707,111 @@
       
  1116  (as of 3.23) are NOT implemented.\n\
       
  1117  ";
       
  1118  
       
  1119 -DL_EXPORT(void)
       
  1120 -init_mysql(void)
       
  1121 +/* module definition */
       
  1122 +static struct PyModuleDef mysqlModule = {
       
  1123 +	PyModuleDef_HEAD_INIT,
       
  1124 +	"_mysql",	/* name of module */
       
  1125 +	_mysql___doc__,		/* module documentation */
       
  1126 +	-1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
       
  1127 +	_mysql_methods,
       
  1128 +	NULL,
       
  1129 +	NULL,
       
  1130 +	NULL,
       
  1131 +	NULL
       
  1132 +};
       
  1133 +
       
  1134 +int CheckError()
       
  1135 +{
       
  1136 +	if ( PyErr_Occurred() )
       
  1137 +	{
       
  1138 +		PyErr_Print();
       
  1139 +		PyErr_SetString(PyExc_ImportError, "_mysql: init failed");
       
  1140 +		PyErr_Print();
       
  1141 +		return -1;
       
  1142 +	};
       
  1143 +	return 0;
       
  1144 +};
       
  1145 +
       
  1146 +PyMODINIT_FUNC PyInit__mysql(void)
       
  1147  {
       
  1148  	PyObject *dict, *module, *emod, *edict;
       
  1149 -	module = Py_InitModule4("_mysql", _mysql_methods, _mysql___doc__,
       
  1150 -				(PyObject *)NULL, PYTHON_API_VERSION);
       
  1151 -	if (!module) return; /* this really should never happen */
       
  1152 -	_mysql_ConnectionObject_Type.ob_type = &PyType_Type;
       
  1153 -	_mysql_ResultObject_Type.ob_type = &PyType_Type;
       
  1154 -#if PY_VERSION_HEX >= 0x02020000
       
  1155 +
       
  1156 +	_mysql_ConnectionObject_Type.ob_base.ob_base.ob_type = &PyType_Type;
       
  1157 +	_mysql_ResultObject_Type.ob_base.ob_base.ob_type = &PyType_Type;
       
  1158  	_mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc;
       
  1159  	_mysql_ConnectionObject_Type.tp_new = PyType_GenericNew;
       
  1160 -	_mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del; 
       
  1161 +	_mysql_ConnectionObject_Type.tp_free = PyObject_GC_Del; 
       
  1162  	_mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc;
       
  1163  	_mysql_ResultObject_Type.tp_new = PyType_GenericNew;
       
  1164 -	_mysql_ResultObject_Type.tp_free = _PyObject_GC_Del;
       
  1165 -#endif
       
  1166 +	_mysql_ResultObject_Type.tp_free = PyObject_GC_Del;
       
  1167  
       
  1168 -	if (!(dict = PyModule_GetDict(module))) goto error;
       
  1169 -	if (PyDict_SetItemString(dict, "version_info",
       
  1170 -			       PyRun_String(QUOTE(version_info), Py_eval_input,
       
  1171 -				       dict, dict)))
       
  1172 -		goto error;
       
  1173 -	if (PyDict_SetItemString(dict, "__version__",
       
  1174 -			       PyString_FromString(QUOTE(__version__))))
       
  1175 -		goto error;
       
  1176 -	if (PyDict_SetItemString(dict, "connection",
       
  1177 -			       (PyObject *)&_mysql_ConnectionObject_Type))
       
  1178 -		goto error;
       
  1179 -	Py_INCREF(&_mysql_ConnectionObject_Type);
       
  1180 -	if (PyDict_SetItemString(dict, "result",
       
  1181 -			       (PyObject *)&_mysql_ResultObject_Type))
       
  1182 -		goto error;	
       
  1183 -	Py_INCREF(&_mysql_ResultObject_Type);
       
  1184 -	if (!(emod = PyImport_ImportModule("_mysql_exceptions")))
       
  1185 -		goto error;
       
  1186 -	if (!(edict = PyModule_GetDict(emod))) goto error;
       
  1187 -	if (!(_mysql_MySQLError =
       
  1188 -	      _mysql_NewException(dict, edict, "MySQLError")))
       
  1189 -		goto error;
       
  1190 -	if (!(_mysql_Warning =
       
  1191 -	      _mysql_NewException(dict, edict, "Warning")))
       
  1192 -		goto error;
       
  1193 -	if (!(_mysql_Error =
       
  1194 -	      _mysql_NewException(dict, edict, "Error")))
       
  1195 -		goto error;
       
  1196 -	if (!(_mysql_InterfaceError =
       
  1197 -	      _mysql_NewException(dict, edict, "InterfaceError")))
       
  1198 -		goto error;
       
  1199 -	if (!(_mysql_DatabaseError =
       
  1200 -	      _mysql_NewException(dict, edict, "DatabaseError")))
       
  1201 -		goto error;
       
  1202 -	if (!(_mysql_DataError =
       
  1203 -	      _mysql_NewException(dict, edict, "DataError")))
       
  1204 -		goto error;
       
  1205 -	if (!(_mysql_OperationalError =
       
  1206 -	      _mysql_NewException(dict, edict, "OperationalError")))
       
  1207 -		goto error;
       
  1208 -	if (!(_mysql_IntegrityError =
       
  1209 -	      _mysql_NewException(dict, edict, "IntegrityError")))
       
  1210 -		goto error;
       
  1211 -	if (!(_mysql_InternalError =
       
  1212 -	      _mysql_NewException(dict, edict, "InternalError")))
       
  1213 -		goto error;
       
  1214 -	if (!(_mysql_ProgrammingError =
       
  1215 -	      _mysql_NewException(dict, edict, "ProgrammingError")))
       
  1216 -		goto error;
       
  1217 -	if (!(_mysql_NotSupportedError =
       
  1218 -	      _mysql_NewException(dict, edict, "NotSupportedError")))
       
  1219 -		goto error;
       
  1220 -	Py_DECREF(emod);
       
  1221 -	if (!(_mysql_NULL = PyString_FromString("NULL")))
       
  1222 -		goto error;
       
  1223 -	if (PyDict_SetItemString(dict, "NULL", _mysql_NULL)) goto error;
       
  1224 -  error:
       
  1225 -	if (PyErr_Occurred())
       
  1226 -		PyErr_SetString(PyExc_ImportError,
       
  1227 -				"_mysql: init failed");
       
  1228 -	return;
       
  1229 +	if (PyType_Ready(&_mysql_ConnectionObject_Type) < 0) return NULL;
       
  1230 +	if (PyType_Ready(&_mysql_ResultObject_Type) < 0) return NULL;
       
  1231 +
       
  1232 +	module = PyModule_Create2(&mysqlModule,PYTHON_API_VERSION);
       
  1233 +	
       
  1234 +	if (module == NULL)
       
  1235 +	{
       
  1236 +		return NULL;
       
  1237 +	};
       
  1238 +	
       
  1239 +	dict = PyModule_GetDict(module);
       
  1240 +	if (PyDict_SetItemString(dict, "version_info", PyRun_String(QUOTE(version_info), Py_eval_input, dict, dict)) == -1)
       
  1241 +	{
       
  1242 +	} else if (PyDict_SetItemString(dict, "__version__",
       
  1243 +			       PyUnicode_FromString(QUOTE(__version__))) == -1 )
       
  1244 +	{
       
  1245 +	} else if (PyDict_SetItemString(dict, "connection",
       
  1246 +			       (PyObject *)&_mysql_ConnectionObject_Type) == -1 )
       
  1247 +	{
       
  1248 +
       
  1249 +	} else
       
  1250 +	{
       
  1251 +		Py_INCREF(&_mysql_ConnectionObject_Type);
       
  1252 +		if ( PyDict_SetItemString(dict, "result",(PyObject *)&_mysql_ResultObject_Type) == -1 )
       
  1253 +		{
       
  1254 +
       
  1255 +		} else
       
  1256 +		{
       
  1257 +			Py_INCREF(&_mysql_ResultObject_Type);
       
  1258 +			emod = PyImport_ImportModule("_mysql_exceptions");
       
  1259 +			if (emod != NULL )
       
  1260 +			{
       
  1261 +				edict = PyModule_GetDict(emod);
       
  1262 +				_mysql_MySQLError = _mysql_NewException(dict, edict, "MySQLError");
       
  1263 +				if (_mysql_MySQLError != NULL)
       
  1264 +				{
       
  1265 +					_mysql_Warning = _mysql_NewException(dict, edict, "Warning");
       
  1266 +					_mysql_Error = _mysql_NewException(dict, edict, "Error");
       
  1267 +					_mysql_InterfaceError = _mysql_NewException(dict, edict, "InterfaceError");
       
  1268 +					_mysql_DatabaseError = _mysql_NewException(dict, edict, "DatabaseError");
       
  1269 +					_mysql_DataError = _mysql_NewException(dict, edict, "DataError");
       
  1270 +					_mysql_OperationalError = _mysql_NewException(dict, edict, "OperationalError");
       
  1271 +					_mysql_IntegrityError = _mysql_NewException(dict, edict, "IntegrityError");
       
  1272 +					_mysql_InternalError = _mysql_NewException(dict, edict, "InternalError");
       
  1273 +					_mysql_ProgrammingError = _mysql_NewException(dict, edict, "ProgrammingError");
       
  1274 +					_mysql_NotSupportedError = _mysql_NewException(dict, edict, "NotSupportedError");
       
  1275 +					if ( _mysql_Warning != NULL && _mysql_Error != NULL && _mysql_InterfaceError != NULL &&
       
  1276 +						 _mysql_DatabaseError != NULL && _mysql_DataError != NULL && _mysql_OperationalError != NULL &&
       
  1277 +						 _mysql_IntegrityError != NULL && _mysql_InternalError != NULL &&
       
  1278 +						 _mysql_ProgrammingError != NULL && _mysql_NotSupportedError != NULL
       
  1279 +					   )
       
  1280 +					{
       
  1281 +						Py_DECREF(emod);
       
  1282 +					    _mysql_NULL = PyUnicode_FromString("NULL");
       
  1283 +					    PyDict_SetItemString(dict, "NULL", _mysql_NULL);
       
  1284 +					};
       
  1285 +				};
       
  1286 +			};
       
  1287 +		};
       
  1288 +	};
       
  1289 +
       
  1290 +	if ( CheckError() == -1 )
       
  1291 +	{
       
  1292 +		return NULL;
       
  1293 +	};
       
  1294 +
       
  1295 +	return module;
       
  1296  }
       
  1297  
       
  1298  
       
  1299 diff -ru MySQL-python-1.2.3/MySQLdb/connections.py MySQL-Python-1.2.3-python3/MySQLdb/connections.py
       
  1300 --- MySQL-python-1.2.3/MySQLdb/connections.py	2010-06-17 09:21:56.000000000 +0200
       
  1301 +++ MySQL-Python-1.2.3-python3/MySQLdb/connections.py	2011-11-25 16:44:27.000000000 +0100
       
  1302 @@ -6,7 +6,7 @@
       
  1303  override Connection.default_cursor with a non-standard Cursor class.
       
  1304  
       
  1305  """
       
  1306 -import cursors
       
  1307 +import MySQLdb.cursors
       
  1308  from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
       
  1309       DatabaseError, OperationalError, IntegrityError, InternalError, \
       
  1310       NotSupportedError, ProgrammingError
       
  1311 @@ -33,7 +33,7 @@
       
  1312          connection.messages.append(error)
       
  1313      del cursor
       
  1314      del connection
       
  1315 -    raise errorclass, errorvalue
       
  1316 +    raise errorclass(errorvalue)
       
  1317  
       
  1318  re_numeric_part = re.compile(r"^(\d+)")
       
  1319  
       
  1320 @@ -57,7 +57,7 @@
       
  1321  
       
  1322      """MySQL Database Connection Object"""
       
  1323  
       
  1324 -    default_cursor = cursors.Cursor
       
  1325 +    default_cursor = MySQLdb.cursors.Cursor
       
  1326      
       
  1327      def __init__(self, *args, **kwargs):
       
  1328          """
       
  1329 @@ -109,17 +109,9 @@
       
  1330          cursorclass
       
  1331            class object, used to create cursors (keyword only)
       
  1332  
       
  1333 -        use_unicode
       
  1334 -          If True, text-like columns are returned as unicode objects
       
  1335 -          using the connection's character set.  Otherwise, text-like
       
  1336 -          columns are returned as strings.  columns are returned as
       
  1337 -          normal strings. Unicode objects will always be encoded to
       
  1338 -          the connection's character set regardless of this setting.
       
  1339 -
       
  1340          charset
       
  1341            If supplied, the connection character set will be changed
       
  1342 -          to this character set (MySQL-4.1 and newer). This implies
       
  1343 -          use_unicode=True.
       
  1344 +          to this character set (MySQL-4.1 and newer).
       
  1345  
       
  1346          sql_mode
       
  1347            If supplied, the session SQL mode will be changed to this
       
  1348 @@ -143,15 +135,15 @@
       
  1349          documentation for the MySQL C API for some hints on what they do.
       
  1350  
       
  1351          """
       
  1352 -        from constants import CLIENT, FIELD_TYPE
       
  1353 -        from converters import conversions
       
  1354 +        from .constants import CLIENT, FIELD_TYPE
       
  1355 +        from .converters import conversions
       
  1356          from weakref import proxy, WeakValueDictionary
       
  1357          
       
  1358          import types
       
  1359  
       
  1360          kwargs2 = kwargs.copy()
       
  1361          
       
  1362 -        if kwargs.has_key('conv'):
       
  1363 +        if 'conv' in kwargs:
       
  1364              conv = kwargs['conv']
       
  1365          else:
       
  1366              conv = conversions
       
  1367 @@ -165,14 +157,8 @@
       
  1368          kwargs2['conv'] = conv2
       
  1369  
       
  1370          self.cursorclass = kwargs2.pop('cursorclass', self.default_cursor)
       
  1371 -        charset = kwargs2.pop('charset', '')
       
  1372 +        charset = kwargs2.pop('charset', 'utf8')
       
  1373  
       
  1374 -        if charset:
       
  1375 -            use_unicode = True
       
  1376 -        else:
       
  1377 -            use_unicode = False
       
  1378 -            
       
  1379 -        use_unicode = kwargs2.pop('use_unicode', use_unicode)
       
  1380          sql_mode = kwargs2.pop('sql_mode', '')
       
  1381  
       
  1382          client_flag = kwargs.get('client_flag', 0)
       
  1383 @@ -197,19 +183,13 @@
       
  1384                  return db.string_literal(obj)
       
  1385              return string_literal
       
  1386  
       
  1387 -        def _get_unicode_literal():
       
  1388 -            def unicode_literal(u, dummy=None):
       
  1389 -                return db.literal(u.encode(unicode_literal.charset))
       
  1390 -            return unicode_literal
       
  1391 -
       
  1392 -        def _get_string_decoder():
       
  1393 -            def string_decoder(s):
       
  1394 -                return s.decode(string_decoder.charset)
       
  1395 -            return string_decoder
       
  1396 -        
       
  1397 +        def _get_bytes_literal():
       
  1398 +            def bytes_literal(u, dummy=None):
       
  1399 +                return db.literal(u.decode(bytes_literal.charset))
       
  1400 +            return bytes_literal
       
  1401 +       
       
  1402          string_literal = _get_string_literal()
       
  1403 -        self.unicode_literal = unicode_literal = _get_unicode_literal()
       
  1404 -        self.string_decoder = string_decoder = _get_string_decoder()
       
  1405 +        self.bytes_literal = bytes_literal = _get_bytes_literal()
       
  1406          if not charset:
       
  1407              charset = self.character_set_name()
       
  1408          self.set_character_set(charset)
       
  1409 @@ -217,14 +197,9 @@
       
  1410          if sql_mode:
       
  1411              self.set_sql_mode(sql_mode)
       
  1412  
       
  1413 -        if use_unicode:
       
  1414 -            self.converter[FIELD_TYPE.STRING].append((None, string_decoder))
       
  1415 -            self.converter[FIELD_TYPE.VAR_STRING].append((None, string_decoder))
       
  1416 -            self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder))
       
  1417 -            self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))
       
  1418 -
       
  1419 -        self.encoders[types.StringType] = string_literal
       
  1420 -        self.encoders[types.UnicodeType] = unicode_literal
       
  1421 +        self.encoders[str] = string_literal
       
  1422 +        self.encoders[bytes] = bytes_literal
       
  1423 +        
       
  1424          self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
       
  1425          if self._transactional:
       
  1426              # PEP-249 requires autocommit to be initially off
       
  1427 @@ -297,8 +272,7 @@
       
  1428                      raise NotSupportedError("server is too old to set charset")
       
  1429                  self.query('SET NAMES %s' % charset)
       
  1430                  self.store_result()
       
  1431 -        self.string_decoder.charset = charset
       
  1432 -        self.unicode_literal.charset = charset
       
  1433 +        self.bytes_literal.charset = charset
       
  1434  
       
  1435      def set_sql_mode(self, sql_mode):
       
  1436          """Set the connection sql_mode. See MySQL documentation for
       
  1437 Pouze v MySQL-python-1.2.3/MySQLdb/constants: .cvsignore
       
  1438 Pouze v MySQL-Python-1.2.3-python3/MySQLdb/constants: __pycache__
       
  1439 diff -ru MySQL-python-1.2.3/MySQLdb/converters.py MySQL-Python-1.2.3-python3/MySQLdb/converters.py
       
  1440 --- MySQL-python-1.2.3/MySQLdb/converters.py	2010-06-17 09:21:56.000000000 +0200
       
  1441 +++ MySQL-Python-1.2.3-python3/MySQLdb/converters.py	2011-10-05 12:49:58.000000000 +0200
       
  1442 @@ -33,9 +33,9 @@
       
  1443  """
       
  1444  
       
  1445  from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
       
  1446 -from constants import FIELD_TYPE, FLAG
       
  1447 -from times import *
       
  1448 -import types
       
  1449 +from .constants import FIELD_TYPE, FLAG
       
  1450 +from .times import *
       
  1451 +import datetime
       
  1452  import array
       
  1453  
       
  1454  try:
       
  1455 @@ -55,16 +55,16 @@
       
  1456      """Convert something into a string via str()."""
       
  1457      return str(s)
       
  1458  
       
  1459 -def Unicode2Str(s, d):
       
  1460 -    """Convert a unicode object to a string using the default encoding.
       
  1461 +def Bytes2Str(s, d):
       
  1462 +    """Convert a bytes object to a string using the default encoding.
       
  1463      This is only used as a placeholder for the real function, which
       
  1464      is connection-dependent."""
       
  1465 -    return s.encode()
       
  1466 +    return s.decode()
       
  1467  
       
  1468  Long2Int = Thing2Str
       
  1469  
       
  1470  def Float2Str(o, d):
       
  1471 -    return '%.15g' % o
       
  1472 +    return '{:f}'.format(o)
       
  1473  
       
  1474  def None2NULL(o, d):
       
  1475      """Convert None to NULL."""
       
  1476 @@ -115,30 +115,30 @@
       
  1477      return Thing2Literal(o.tostring(), d)
       
  1478  
       
  1479  conversions = {
       
  1480 -    types.IntType: Thing2Str,
       
  1481 -    types.LongType: Long2Int,
       
  1482 -    types.FloatType: Float2Str,
       
  1483 -    types.NoneType: None2NULL,
       
  1484 -    types.TupleType: escape_sequence,
       
  1485 -    types.ListType: escape_sequence,
       
  1486 -    types.DictType: escape_dict,
       
  1487 -    types.InstanceType: Instance2Str,
       
  1488 +    int: Long2Int,
       
  1489 +    float: Float2Str,
       
  1490 +    type(None): None2NULL,
       
  1491 +    tuple: escape_sequence,
       
  1492 +    list: escape_sequence,
       
  1493 +    dict: escape_dict,
       
  1494 +    object: Instance2Str,
       
  1495      array.ArrayType: array2Str,
       
  1496 -    types.StringType: Thing2Literal, # default
       
  1497 -    types.UnicodeType: Unicode2Str,
       
  1498 -    types.ObjectType: Instance2Str,
       
  1499 -    types.BooleanType: Bool2Str,
       
  1500 -    DateTimeType: DateTime2literal,
       
  1501 -    DateTimeDeltaType: DateTimeDelta2literal,
       
  1502 +    str: Thing2Literal, # default
       
  1503 +    bytes: Bytes2Str,
       
  1504 +    bool: Bool2Str,
       
  1505 +    datetime.date: DateTime2literal,
       
  1506 +    datetime.time: DateTime2literal,
       
  1507 +    datetime.datetime: DateTime2literal,
       
  1508 +    datetime.timedelta: DateTimeDelta2literal,
       
  1509      set: Set2Str,
       
  1510      FIELD_TYPE.TINY: int,
       
  1511      FIELD_TYPE.SHORT: int,
       
  1512 -    FIELD_TYPE.LONG: long,
       
  1513 +    FIELD_TYPE.LONG: int,
       
  1514      FIELD_TYPE.FLOAT: float,
       
  1515      FIELD_TYPE.DOUBLE: float,
       
  1516      FIELD_TYPE.DECIMAL: float,
       
  1517      FIELD_TYPE.NEWDECIMAL: float,
       
  1518 -    FIELD_TYPE.LONGLONG: long,
       
  1519 +    FIELD_TYPE.LONGLONG: int,
       
  1520      FIELD_TYPE.INT24: int,
       
  1521      FIELD_TYPE.YEAR: int,
       
  1522      FIELD_TYPE.SET: Str2Set,
       
  1523 diff -ru MySQL-python-1.2.3/MySQLdb/cursors.py MySQL-Python-1.2.3-python3/MySQLdb/cursors.py
       
  1524 --- MySQL-python-1.2.3/MySQLdb/cursors.py	2010-06-17 09:21:56.000000000 +0200
       
  1525 +++ MySQL-Python-1.2.3-python3/MySQLdb/cursors.py	2011-11-25 16:53:26.000000000 +0100
       
  1526 @@ -7,7 +7,6 @@
       
  1527  
       
  1528  import re
       
  1529  import sys
       
  1530 -from types import ListType, TupleType, UnicodeType
       
  1531  
       
  1532  
       
  1533  restr = (r"\svalues\s*"
       
  1534 @@ -153,13 +152,19 @@
       
  1535          del self.messages[:]
       
  1536          db = self._get_db()
       
  1537          charset = db.character_set_name()
       
  1538 -        if isinstance(query, unicode):
       
  1539 -            query = query.encode(charset)
       
  1540 +
       
  1541          if args is not None:
       
  1542 +            if isinstance(query, bytes):
       
  1543 +                query = query.decode();
       
  1544 +
       
  1545              query = query % db.literal(args)
       
  1546 +
       
  1547 +        if isinstance(query, str):
       
  1548 +            query = query.encode(charset);
       
  1549 +
       
  1550          try:
       
  1551              r = self._query(query)
       
  1552 -        except TypeError, m:
       
  1553 +        except TypeError as m:
       
  1554              if m.args[0] in ("not enough arguments for format string",
       
  1555                               "not all arguments converted"):
       
  1556                  self.messages.append((ProgrammingError, m.args[0]))
       
  1557 @@ -197,8 +202,6 @@
       
  1558          del self.messages[:]
       
  1559          db = self._get_db()
       
  1560          if not args: return
       
  1561 -        charset = db.character_set_name()
       
  1562 -        if isinstance(query, unicode): query = query.encode(charset)
       
  1563          m = insert_values.search(query)
       
  1564          if not m:
       
  1565              r = 0
       
  1566 @@ -210,7 +213,7 @@
       
  1567          qv = m.group(1)
       
  1568          try:
       
  1569              q = [ qv % db.literal(a) for a in args ]
       
  1570 -        except TypeError, msg:
       
  1571 +        except TypeError as msg:
       
  1572              if msg.args[0] in ("not enough arguments for format string",
       
  1573                                 "not all arguments converted"):
       
  1574                  self.errorhandler(self, ProgrammingError, msg.args[0])
       
  1575 @@ -259,7 +262,7 @@
       
  1576          for index, arg in enumerate(args):
       
  1577              q = "SET @_%s_%d=%s" % (procname, index,
       
  1578                                           db.literal(arg))
       
  1579 -            if isinstance(q, unicode):
       
  1580 +            if isinstance(q, str):
       
  1581                  q = q.encode(charset)
       
  1582              self._query(q)
       
  1583              self.nextset()
       
  1584 @@ -267,7 +270,7 @@
       
  1585          q = "CALL %s(%s)" % (procname,
       
  1586                               ','.join(['@_%s_%d' % (procname, i)
       
  1587                                         for i in range(len(args))]))
       
  1588 -        if type(q) is UnicodeType:
       
  1589 +        if type(q) is str:
       
  1590              q = q.encode(charset)
       
  1591          self._query(q)
       
  1592          self._executed = q
       
  1593 @@ -363,7 +366,7 @@
       
  1594              r = value
       
  1595          else:
       
  1596              self.errorhandler(self, ProgrammingError,
       
  1597 -                              "unknown scroll mode %s" % `mode`)
       
  1598 +                              "unknown scroll mode %r" % mode)
       
  1599          if r < 0 or r >= len(self._rows):
       
  1600              self.errorhandler(self, IndexError, "out of range")
       
  1601          self.rownumber = r
       
  1602 Pouze v MySQL-python-1.2.3/MySQLdb: .cvsignore
       
  1603 diff -ru MySQL-python-1.2.3/MySQLdb/__init__.py MySQL-Python-1.2.3-python3/MySQLdb/__init__.py
       
  1604 --- MySQL-python-1.2.3/MySQLdb/__init__.py	2010-06-17 09:21:56.000000000 +0200
       
  1605 +++ MySQL-Python-1.2.3-python3/MySQLdb/__init__.py	2011-10-05 12:49:58.000000000 +0200
       
  1606 @@ -14,7 +14,7 @@
       
  1607  """
       
  1608  
       
  1609  __revision__ = """$Revision: 603 $"""[11:-2]
       
  1610 -from release import __version__, version_info, __author__
       
  1611 +from .release import __version__, version_info, __author__
       
  1612  
       
  1613  import _mysql
       
  1614  
       
  1615 @@ -77,7 +77,7 @@
       
  1616  
       
  1617  def Connect(*args, **kwargs):
       
  1618      """Factory function for connections.Connection."""
       
  1619 -    from connections import Connection
       
  1620 +    from .connections import Connection
       
  1621      return Connection(*args, **kwargs)
       
  1622  
       
  1623  connect = Connection = Connect
       
  1624 diff -ru MySQL-python-1.2.3/_mysql_exceptions.py MySQL-Python-1.2.3-python3/_mysql_exceptions.py
       
  1625 --- MySQL-python-1.2.3/_mysql_exceptions.py	2010-06-17 09:21:56.000000000 +0200
       
  1626 +++ MySQL-Python-1.2.3-python3/_mysql_exceptions.py	2011-10-05 12:49:58.000000000 +0200
       
  1627 @@ -5,9 +5,8 @@
       
  1628      http://www.python.org/topics/database/DatabaseAPI-2.0.html
       
  1629  """
       
  1630  
       
  1631 -from exceptions import Exception, StandardError, Warning
       
  1632  
       
  1633 -class MySQLError(StandardError):
       
  1634 +class MySQLError(Exception):
       
  1635      
       
  1636      """Exception related to operation with MySQL."""
       
  1637  
       
  1638 @@ -80,4 +79,3 @@
       
  1639      has transactions turned off."""
       
  1640  
       
  1641  
       
  1642 -del Exception, StandardError
       
  1643 diff -ru MySQL-python-1.2.3/MySQL_python.egg-info/SOURCES.txt MySQL-Python-1.2.3-python3/MySQL_python.egg-info/SOURCES.txt
       
  1644 --- MySQL-python-1.2.3/MySQL_python.egg-info/SOURCES.txt	2010-06-17 09:22:07.000000000 +0200
       
  1645 +++ MySQL-Python-1.2.3-python3/MySQL_python.egg-info/SOURCES.txt	2011-11-25 16:54:24.000000000 +0100
       
  1646 @@ -1,4 +1,3 @@
       
  1647 -.cvsignore
       
  1648  HISTORY
       
  1649  MANIFEST.in
       
  1650  README
       
  1651 @@ -17,14 +16,12 @@
       
  1652  MySQL_python.egg-info/SOURCES.txt
       
  1653  MySQL_python.egg-info/dependency_links.txt
       
  1654  MySQL_python.egg-info/top_level.txt
       
  1655 -MySQLdb/.cvsignore
       
  1656  MySQLdb/__init__.py
       
  1657  MySQLdb/connections.py
       
  1658  MySQLdb/converters.py
       
  1659  MySQLdb/cursors.py
       
  1660  MySQLdb/release.py
       
  1661  MySQLdb/times.py
       
  1662 -MySQLdb/constants/.cvsignore
       
  1663  MySQLdb/constants/CLIENT.py
       
  1664  MySQLdb/constants/CR.py
       
  1665  MySQLdb/constants/ER.py
       
  1666 @@ -32,7 +29,6 @@
       
  1667  MySQLdb/constants/FLAG.py
       
  1668  MySQLdb/constants/REFRESH.py
       
  1669  MySQLdb/constants/__init__.py
       
  1670 -doc/.cvsignore
       
  1671  doc/FAQ.txt
       
  1672  doc/MySQLdb.txt
       
  1673  tests/capabilities.py
       
  1674 diff -ru MySQL-python-1.2.3/README MySQL-Python-1.2.3-python3/README
       
  1675 --- MySQL-python-1.2.3/README	2010-06-17 09:21:56.000000000 +0200
       
  1676 +++ MySQL-Python-1.2.3-python3/README	2011-10-05 12:49:58.000000000 +0200
       
  1677 @@ -8,22 +8,18 @@
       
  1678  Prerequisites
       
  1679  -------------
       
  1680  
       
  1681 -+ Python 2.3.4 or higher
       
  1682 ++ Python 3.2 or higher
       
  1683  
       
  1684    * http://www.python.org/
       
  1685  
       
  1686 -  * Versions lower than 2.3 WON'T WORK.
       
  1687 -
       
  1688 -  * 2.4 is the primary test environment.
       
  1689 -
       
  1690    * Red Hat Linux:
       
  1691  
       
  1692      - Make sure you have the Python development headers and libraries
       
  1693        (python-devel).
       
  1694  
       
  1695 -+ setuptools
       
  1696 ++ distribute
       
  1697  
       
  1698 -  * http://pypi.python.org/pypi/setuptools
       
  1699 +  * http://pypi.python.org/pypi/distribute/
       
  1700  
       
  1701  + MySQL 3.23.32 or higher
       
  1702  
       
  1703 diff -ru MySQL-python-1.2.3/setup_common.py MySQL-Python-1.2.3-python3/setup_common.py
       
  1704 --- MySQL-python-1.2.3/setup_common.py	2010-06-17 09:21:56.000000000 +0200
       
  1705 +++ MySQL-Python-1.2.3-python3/setup_common.py	2011-10-05 12:49:58.000000000 +0200
       
  1706 @@ -1,4 +1,4 @@
       
  1707 -from ConfigParser import SafeConfigParser
       
  1708 +from configparser import SafeConfigParser
       
  1709  
       
  1710  def get_metadata_and_options():
       
  1711      config = SafeConfigParser()
       
  1712 @@ -7,8 +7,8 @@
       
  1713      metadata = dict(config.items('metadata'))
       
  1714      options = dict(config.items('options'))
       
  1715  
       
  1716 -    metadata['py_modules'] = filter(None, metadata['py_modules'].split('\n'))
       
  1717 -    metadata['classifiers'] = filter(None, metadata['classifiers'].split('\n'))
       
  1718 +    metadata['py_modules'] = list(filter(None, metadata['py_modules'].split('\n')))
       
  1719 +    metadata['classifiers'] = list(filter(None, metadata['classifiers'].split('\n')))
       
  1720  
       
  1721      return metadata, options
       
  1722  
       
  1723 @@ -30,3 +30,4 @@
       
  1724  __version__ = "%(version)s"
       
  1725  """ % metadata)
       
  1726      rel.close()
       
  1727 +
       
  1728 diff -ru MySQL-python-1.2.3/setup_posix.py MySQL-Python-1.2.3-python3/setup_posix.py
       
  1729 --- MySQL-python-1.2.3/setup_posix.py	2010-06-17 09:21:56.000000000 +0200
       
  1730 +++ MySQL-Python-1.2.3-python3/setup_posix.py	2011-11-25 17:13:11.000000000 +0100
       
  1731 @@ -1,4 +1,4 @@
       
  1732 -from ConfigParser import SafeConfigParser
       
  1733 +from configparser import SafeConfigParser
       
  1734  
       
  1735  # This dequote() business is required for some older versions
       
  1736  # of mysql_config
       
  1737 @@ -98,5 +98,5 @@
       
  1738      return metadata, ext_options
       
  1739  
       
  1740  if __name__ == "__main__":
       
  1741 -    print """You shouldn't be running this directly; it is used by setup.py."""
       
  1742 +    print("""You shouldn't be running this directly; it is used by setup.py.""")
       
  1743  
       
  1744 diff -ru MySQL-python-1.2.3/setup.py MySQL-Python-1.2.3-python3/setup.py
       
  1745 --- MySQL-python-1.2.3/setup.py	2010-06-17 09:21:56.000000000 +0200
       
  1746 +++ MySQL-Python-1.2.3-python3/setup.py	2011-10-05 12:49:58.000000000 +0200
       
  1747 @@ -4,8 +4,8 @@
       
  1748  import sys
       
  1749  from setuptools import setup, Extension
       
  1750  
       
  1751 -if not hasattr(sys, "hexversion") or sys.hexversion < 0x02030000:
       
  1752 -    raise Error("Python 2.3 or newer is required")
       
  1753 +if not hasattr(sys, "hexversion") or sys.hexversion < 0x03000000:
       
  1754 +    raise Exception("Python 3.0 or newer is required")
       
  1755  
       
  1756  if os.name == "posix":
       
  1757      from setup_posix import get_config
       
  1758 diff -ru MySQL-python-1.2.3/setup_windows.py MySQL-Python-1.2.3-python3/setup_windows.py
       
  1759 --- MySQL-python-1.2.3/setup_windows.py	2010-06-17 09:21:56.000000000 +0200
       
  1760 +++ MySQL-Python-1.2.3-python3/setup_windows.py	2011-10-05 12:49:58.000000000 +0200
       
  1761 @@ -1,11 +1,11 @@
       
  1762  def get_config():
       
  1763 -    import os, sys, _winreg
       
  1764 +    import os, sys, winreg
       
  1765      from setup_common import get_metadata_and_options, enabled, create_release_file
       
  1766  
       
  1767      metadata, options = get_metadata_and_options()
       
  1768  
       
  1769 -    serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
       
  1770 -    mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')
       
  1771 +    serverKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
       
  1772 +    mysql_root, dummy = winreg.QueryValueEx(serverKey,options['location'])
       
  1773  
       
  1774      extra_objects = []
       
  1775      static = enabled(options, 'static')
       
  1776 @@ -15,7 +15,7 @@
       
  1777      else:
       
  1778          client = "mysqlclient"
       
  1779  
       
  1780 -    library_dirs = [ os.path.join(mysql_root, r'lib\opt') ]
       
  1781 +    library_dirs = [ os.path.join(mysql_root, r'lib') ]
       
  1782      libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
       
  1783      include_dirs = [ os.path.join(mysql_root, r'include') ]
       
  1784      extra_compile_args = [ '/Zl' ]
       
  1785 @@ -43,5 +43,5 @@
       
  1786      return metadata, ext_options
       
  1787  
       
  1788  if __name__ == "__main__":
       
  1789 -    print """You shouldn't be running this directly; it is used by setup.py."""
       
  1790 +    print ("""You shouldn't be running this directly; it is used by setup.py.""")
       
  1791      
       
  1792 diff -ru MySQL-python-1.2.3/site.cfg MySQL-Python-1.2.3-python3/site.cfg
       
  1793 --- MySQL-python-1.2.3/site.cfg	2010-06-17 09:21:56.000000000 +0200
       
  1794 +++ MySQL-Python-1.2.3-python3/site.cfg	2011-10-05 12:49:58.000000000 +0200
       
  1795 @@ -15,4 +15,6 @@
       
  1796  # The Windows registry key for MySQL.
       
  1797  # This has to be set for Windows builds to work.
       
  1798  # Only change this if you have a different version.
       
  1799 -registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
       
  1800 +registry_key = SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2DB39FB6-161E-44E7-B2A1-B654C85EFBC1}
       
  1801 +location = InstallLocation
       
  1802 +
       
  1803 diff -ru MySQL-python-1.2.3/tests/capabilities.py MySQL-Python-1.2.3-python3/tests/capabilities.py
       
  1804 --- MySQL-python-1.2.3/tests/capabilities.py	2010-06-17 09:21:55.000000000 +0200
       
  1805 +++ MySQL-Python-1.2.3-python3/tests/capabilities.py	2011-10-05 12:49:58.000000000 +0200
       
  1806 @@ -25,7 +25,7 @@
       
  1807          self.connection = db
       
  1808          self.cursor = db.cursor()
       
  1809          self.BLOBText = ''.join([chr(i) for i in range(256)] * 100);
       
  1810 -        self.BLOBUText = u''.join([unichr(i) for i in range(16384)])
       
  1811 +        self.BLOBUText = ''.join([chr(i) for i in range(16384)])
       
  1812          self.BLOBBinary = self.db_module.Binary(''.join([chr(i) for i in range(256)] * 16))
       
  1813  
       
  1814      leak_test = True
       
  1815 @@ -35,11 +35,11 @@
       
  1816              import gc
       
  1817              del self.cursor
       
  1818              orphans = gc.collect()
       
  1819 -            self.failIf(orphans, "%d orphaned objects found after deleting cursor" % orphans)
       
  1820 +            self.assertFalse(orphans, "%d orphaned objects found after deleting cursor" % orphans)
       
  1821              
       
  1822              del self.connection
       
  1823              orphans = gc.collect()
       
  1824 -            self.failIf(orphans, "%d orphaned objects found after deleting connection" % orphans)
       
  1825 +            self.assertFalse(orphans, "%d orphaned objects found after deleting connection" % orphans)
       
  1826              
       
  1827      def table_exists(self, name):
       
  1828          try:
       
  1829 @@ -81,18 +81,18 @@
       
  1830          self.create_table(columndefs)
       
  1831          insert_statement = ('INSERT INTO %s VALUES (%s)' % 
       
  1832                              (self.table,
       
  1833 -                             ','.join(['%s'] * len(columndefs))))
       
  1834 +                             ','.join(['{!s}'] * len(columndefs))))
       
  1835          data = [ [ generator(i,j) for j in range(len(columndefs)) ]
       
  1836                   for i in range(self.rows) ]
       
  1837          if self.debug:
       
  1838 -            print data
       
  1839 +            print(data)
       
  1840          self.cursor.executemany(insert_statement, data)
       
  1841          self.connection.commit()
       
  1842          # verify
       
  1843          self.cursor.execute('select * from %s' % self.table)
       
  1844          l = self.cursor.fetchall()
       
  1845          if self.debug:
       
  1846 -            print l
       
  1847 +            print(l)
       
  1848          self.assertEquals(len(l), self.rows)
       
  1849          try:
       
  1850              for i in range(self.rows):
       
  1851 @@ -110,7 +110,7 @@
       
  1852          self.create_table(columndefs)
       
  1853          insert_statement = ('INSERT INTO %s VALUES (%s)' % 
       
  1854                              (self.table,
       
  1855 -                             ','.join(['%s'] * len(columndefs))))
       
  1856 +                             ','.join(['{!s}'] * len(columndefs))))
       
  1857          data = [ [ generator(i,j) for j in range(len(columndefs)) ]
       
  1858                   for i in range(self.rows) ]
       
  1859          self.cursor.executemany(insert_statement, data)
       
  1860 @@ -122,33 +122,33 @@
       
  1861          for i in range(self.rows):
       
  1862              for j in range(len(columndefs)):
       
  1863                  self.assertEquals(l[i][j], generator(i,j))
       
  1864 -        delete_statement = 'delete from %s where col1=%%s' % self.table
       
  1865 +        delete_statement = 'delete from %s where col1={!s}' % self.table
       
  1866          self.cursor.execute(delete_statement, (0,))
       
  1867          self.cursor.execute('select col1 from %s where col1=%s' % \
       
  1868                              (self.table, 0))
       
  1869          l = self.cursor.fetchall()
       
  1870 -        self.failIf(l, "DELETE didn't work")
       
  1871 +        self.assertFalse(l, "DELETE didn't work")
       
  1872          self.connection.rollback()
       
  1873          self.cursor.execute('select col1 from %s where col1=%s' % \
       
  1874                              (self.table, 0))
       
  1875          l = self.cursor.fetchall()
       
  1876 -        self.failUnless(len(l) == 1, "ROLLBACK didn't work")
       
  1877 +        self.assertTrue(len(l) == 1, "ROLLBACK didn't work")
       
  1878          self.cursor.execute('drop table %s' % (self.table))
       
  1879  
       
  1880      def test_truncation(self):
       
  1881          columndefs = ( 'col1 INT', 'col2 VARCHAR(255)')
       
  1882          def generator(row, col):
       
  1883              if col == 0: return row
       
  1884 -            else: return ('%i' % (row%10))*((255-self.rows/2)+row)
       
  1885 +            else: return ('{:d}'.format(row%10))*(round(255-self.rows/2)+row)
       
  1886          self.create_table(columndefs)
       
  1887          insert_statement = ('INSERT INTO %s VALUES (%s)' % 
       
  1888                              (self.table,
       
  1889 -                             ','.join(['%s'] * len(columndefs))))
       
  1890 +                             ','.join(['{!s}'] * len(columndefs))))
       
  1891  
       
  1892          try:
       
  1893              self.cursor.execute(insert_statement, (0, '0'*256))
       
  1894          except Warning:
       
  1895 -            if self.debug: print self.cursor.messages
       
  1896 +            if self.debug: print(self.cursor.messages)
       
  1897          except self.connection.DataError:
       
  1898              pass
       
  1899          else:
       
  1900 @@ -163,7 +163,7 @@
       
  1901                      data.append(generator(i,j))
       
  1902                  self.cursor.execute(insert_statement,tuple(data))
       
  1903          except Warning:
       
  1904 -            if self.debug: print self.cursor.messages
       
  1905 +            if self.debug: print(self.cursor.messages)
       
  1906          except self.connection.DataError:
       
  1907              pass
       
  1908          else:
       
  1909 @@ -176,7 +176,7 @@
       
  1910                       for i in range(self.rows) ]
       
  1911              self.cursor.executemany(insert_statement, data)
       
  1912          except Warning:
       
  1913 -            if self.debug: print self.cursor.messages
       
  1914 +            if self.debug: print(self.cursor.messages)
       
  1915          except self.connection.DataError:
       
  1916              pass
       
  1917          else:
       
  1918 diff -ru MySQL-python-1.2.3/tests/dbapi20.py MySQL-Python-1.2.3-python3/tests/dbapi20.py
       
  1919 --- MySQL-python-1.2.3/tests/dbapi20.py	2010-06-17 09:21:55.000000000 +0200
       
  1920 +++ MySQL-Python-1.2.3-python3/tests/dbapi20.py	2011-10-05 12:49:58.000000000 +0200
       
  1921 @@ -177,8 +177,8 @@
       
  1922      def test_Exceptions(self):
       
  1923          # Make sure required exceptions exist, and are in the
       
  1924          # defined heirarchy.
       
  1925 -        self.failUnless(issubclass(self.driver.Warning,StandardError))
       
  1926 -        self.failUnless(issubclass(self.driver.Error,StandardError))
       
  1927 +        self.failUnless(issubclass(self.driver.Warning,Exception))
       
  1928 +        self.failUnless(issubclass(self.driver.Error,Exception))
       
  1929          self.failUnless(
       
  1930              issubclass(self.driver.InterfaceError,self.driver.Error)
       
  1931              )
       
  1932 @@ -382,27 +382,27 @@
       
  1933  
       
  1934          if self.driver.paramstyle == 'qmark':
       
  1935              cur.execute(
       
  1936 -                'insert into %sbooze values (?)' % self.table_prefix,
       
  1937 +                'insert into %sbooze values ({!s})' % self.table_prefix,
       
  1938                  ("Cooper's",)
       
  1939                  )
       
  1940          elif self.driver.paramstyle == 'numeric':
       
  1941              cur.execute(
       
  1942 -                'insert into %sbooze values (:1)' % self.table_prefix,
       
  1943 +                'insert into %sbooze values ({:1})' % self.table_prefix,
       
  1944                  ("Cooper's",)
       
  1945                  )
       
  1946          elif self.driver.paramstyle == 'named':
       
  1947              cur.execute(
       
  1948 -                'insert into %sbooze values (:beer)' % self.table_prefix, 
       
  1949 +                'insert into %sbooze values ({beer})' % self.table_prefix, 
       
  1950                  {'beer':"Cooper's"}
       
  1951                  )
       
  1952          elif self.driver.paramstyle == 'format':
       
  1953              cur.execute(
       
  1954 -                'insert into %sbooze values (%%s)' % self.table_prefix,
       
  1955 +                'insert into %sbooze values ({!s})' % self.table_prefix,
       
  1956                  ("Cooper's",)
       
  1957                  )
       
  1958          elif self.driver.paramstyle == 'pyformat':
       
  1959              cur.execute(
       
  1960 -                'insert into %sbooze values (%%(beer)s)' % self.table_prefix,
       
  1961 +                'insert into %sbooze values ({beer})' % self.table_prefix,
       
  1962                  {'beer':"Cooper's"}
       
  1963                  )
       
  1964          else:
       
  1965 @@ -432,27 +432,27 @@
       
  1966              margs = [ {'beer': "Cooper's"}, {'beer': "Boag's"} ]
       
  1967              if self.driver.paramstyle == 'qmark':
       
  1968                  cur.executemany(
       
  1969 -                    'insert into %sbooze values (?)' % self.table_prefix,
       
  1970 +                    'insert into %sbooze values ({!s})' % self.table_prefix,
       
  1971                      largs
       
  1972                      )
       
  1973              elif self.driver.paramstyle == 'numeric':
       
  1974                  cur.executemany(
       
  1975 -                    'insert into %sbooze values (:1)' % self.table_prefix,
       
  1976 +                    'insert into %sbooze values ({:1})' % self.table_prefix,
       
  1977                      largs
       
  1978                      )
       
  1979              elif self.driver.paramstyle == 'named':
       
  1980                  cur.executemany(
       
  1981 -                    'insert into %sbooze values (:beer)' % self.table_prefix,
       
  1982 +                    'insert into %sbooze values ({beer})' % self.table_prefix,
       
  1983                      margs
       
  1984                      )
       
  1985              elif self.driver.paramstyle == 'format':
       
  1986                  cur.executemany(
       
  1987 -                    'insert into %sbooze values (%%s)' % self.table_prefix,
       
  1988 +                    'insert into %sbooze values ({!s})' % self.table_prefix,
       
  1989                      largs
       
  1990                      )
       
  1991              elif self.driver.paramstyle == 'pyformat':
       
  1992                  cur.executemany(
       
  1993 -                    'insert into %sbooze values (%%(beer)s)' % (
       
  1994 +                    'insert into %sbooze values ({beer})' % (
       
  1995                          self.table_prefix
       
  1996                          ),
       
  1997                      margs
       
  1998 @@ -706,7 +706,7 @@
       
  1999              that returns two result sets, first the 
       
  2000  	    number of rows in booze then "name from booze"
       
  2001          '''
       
  2002 -        raise NotImplementedError,'Helper not implemented'
       
  2003 +        raise NotImplementedError('Helper not implemented')
       
  2004          #sql="""
       
  2005          #    create procedure deleteme as
       
  2006          #    begin
       
  2007 @@ -718,7 +718,7 @@
       
  2008  
       
  2009      def help_nextset_tearDown(self,cur):
       
  2010          'If cleaning up is needed after nextSetTest'
       
  2011 -        raise NotImplementedError,'Helper not implemented'
       
  2012 +        raise NotImplementedError('Helper not implemented')
       
  2013          #cur.execute("drop procedure deleteme")
       
  2014  
       
  2015      def test_nextset(self):
       
  2016 @@ -751,7 +751,7 @@
       
  2017              con.close()
       
  2018  
       
  2019      def test_nextset(self):
       
  2020 -        raise NotImplementedError,'Drivers need to override this test'
       
  2021 +        raise NotImplementedError('Drivers need to override this test')
       
  2022  
       
  2023      def test_arraysize(self):
       
  2024          # Not much here - rest of the tests for this are in test_fetchmany
       
  2025 @@ -786,7 +786,7 @@
       
  2026  
       
  2027      def test_setoutputsize(self):
       
  2028          # Real test for setoutputsize is driver dependant
       
  2029 -        raise NotImplementedError,'Driver need to override this test'
       
  2030 +        raise NotImplementedError('Driver need to override this test')
       
  2031  
       
  2032      def test_None(self):
       
  2033          con = self._connect()
       
  2034 diff -ru MySQL-python-1.2.3/tests/test_MySQLdb_capabilities.py MySQL-Python-1.2.3-python3/tests/test_MySQLdb_capabilities.py
       
  2035 --- MySQL-python-1.2.3/tests/test_MySQLdb_capabilities.py	2010-06-17 09:21:55.000000000 +0200
       
  2036 +++ MySQL-Python-1.2.3-python3/tests/test_MySQLdb_capabilities.py	2011-10-05 12:49:58.000000000 +0200
       
  2037 @@ -41,8 +41,7 @@
       
  2038          db = self.connection
       
  2039          c = self.cursor
       
  2040          self.create_table(('pos INT', 'tree CHAR(20)'))
       
  2041 -        c.executemany("INSERT INTO %s (pos,tree) VALUES (%%s,%%s)" % self.table,
       
  2042 -                      list(enumerate('ash birch cedar larch pine'.split())))
       
  2043 +        c.executemany("INSERT INTO %s (pos,tree) VALUES ({!s},{!s})" % self.table, list(enumerate('ash birch cedar larch pine'.split())) )
       
  2044          db.commit()
       
  2045          
       
  2046          c.execute("""
       
  2047 @@ -77,9 +76,9 @@
       
  2048          from MySQLdb.constants import ER
       
  2049          try:
       
  2050              self.cursor.execute("describe some_non_existent_table");
       
  2051 -        except self.connection.ProgrammingError, msg:
       
  2052 -            self.failUnless(msg[0] == ER.NO_SUCH_TABLE)
       
  2053 -    
       
  2054 +        except self.connection.ProgrammingError as msg:
       
  2055 +            self.assertTrue(msg.code == ER.NO_SUCH_TABLE)
       
  2056 +        
       
  2057      def test_ping(self):
       
  2058          self.connection.ping()
       
  2059          
       
  2060 @@ -90,4 +89,4 @@
       
  2061          gc.enable()
       
  2062          gc.set_debug(gc.DEBUG_LEAK)
       
  2063      unittest.main()
       
  2064 -    print '''"Huh-huh, he said 'unit'." -- Butthead'''
       
  2065 +    print ('''"Huh-huh, he said 'unit'." -- Butthead''')
       
  2066 diff -ru MySQL-python-1.2.3/tests/test_MySQLdb_dbapi20.py MySQL-Python-1.2.3-python3/tests/test_MySQLdb_dbapi20.py
       
  2067 --- MySQL-python-1.2.3/tests/test_MySQLdb_dbapi20.py	2010-06-17 09:21:55.000000000 +0200
       
  2068 +++ MySQL-Python-1.2.3-python3/tests/test_MySQLdb_dbapi20.py	2011-10-05 12:49:58.000000000 +0200
       
  2069 @@ -202,4 +202,4 @@
       
  2070      
       
  2071  if __name__ == '__main__':
       
  2072      unittest.main()
       
  2073 -    print '''"Huh-huh, he said 'unit'." -- Butthead'''
       
  2074 +    print ('''"Huh-huh, he said 'unit'." -- Butthead''')