Mercurial > p > mysql-python > mysqldb-2
comparison _mysql_connections.c @ 29:fbf2470ea3d4 MySQLdb
Remove more pre-2.3 checks and #define work-arounds.
author | kylev |
---|---|
date | Mon, 09 Feb 2009 01:48:38 +0000 |
parents | 25c5d3b241ba |
children | fdf0cabb27be |
comparison
equal
deleted
inserted
replaced
28:5a3e4cafadec | 29:fbf2470ea3d4 |
---|---|
1 /* -*- mode: C; indent-tabs-mode: t; c-basic-offset: 8; -*- */ | |
2 | |
1 #include "_mysql.h" | 3 #include "_mysql.h" |
2 | 4 |
3 static int | 5 static int |
4 _mysql_ConnectionObject_Initialize( | 6 _mysql_ConnectionObject_Initialize( |
5 _mysql_ConnectionObject *self, | 7 _mysql_ConnectionObject *self, |
45 &client_flag, &ssl, | 47 &client_flag, &ssl, |
46 &local_infile | 48 &local_infile |
47 )) | 49 )) |
48 return -1; | 50 return -1; |
49 | 51 |
50 if (!conv) | 52 /* Keep the converter mapping or a blank mapping dict */ |
53 if (!conv) | |
51 conv = PyDict_New(); | 54 conv = PyDict_New(); |
52 #if PY_VERSION_HEX > 0x02000100 | |
53 else | 55 else |
54 Py_INCREF(conv); | 56 Py_INCREF(conv); |
55 #endif | |
56 if (!conv) | 57 if (!conv) |
57 return -1; | 58 return -1; |
58 self->converter = conv; | 59 self->converter = conv; |
59 | 60 |
60 #define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\ | 61 #define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\ |
193 c = NULL; | 194 c = NULL; |
194 } | 195 } |
195 return (PyObject *) c; | 196 return (PyObject *) c; |
196 } | 197 } |
197 | 198 |
198 #if PY_VERSION_HEX >= 0x02020000 | |
199 static int _mysql_ConnectionObject_traverse( | 199 static int _mysql_ConnectionObject_traverse( |
200 _mysql_ConnectionObject *self, | 200 _mysql_ConnectionObject *self, |
201 visitproc visit, | 201 visitproc visit, |
202 void *arg) | 202 void *arg) |
203 { | 203 { |
204 if (self->converter) | 204 if (self->converter) |
205 return visit(self->converter, arg); | 205 return visit(self->converter, arg); |
206 return 0; | 206 return 0; |
207 } | 207 } |
208 #endif | |
209 | 208 |
210 static int _mysql_ConnectionObject_clear( | 209 static int _mysql_ConnectionObject_clear( |
211 _mysql_ConnectionObject *self) | 210 _mysql_ConnectionObject *self) |
212 { | 211 { |
213 Py_XDECREF(self->converter); | 212 Py_XDECREF(self->converter); |
1413 | 1412 |
1414 PyTypeObject _mysql_ConnectionObject_Type = { | 1413 PyTypeObject _mysql_ConnectionObject_Type = { |
1415 PyObject_HEAD_INIT(NULL) | 1414 PyObject_HEAD_INIT(NULL) |
1416 0, | 1415 0, |
1417 "_mysql.connection", /* (char *)tp_name For printing */ | 1416 "_mysql.connection", /* (char *)tp_name For printing */ |
1418 sizeof(_mysql_ConnectionObject), | 1417 sizeof(_mysql_ConnectionObject), /* tp_basicsize */ |
1419 0, | 1418 0, |
1420 (destructor)_mysql_ConnectionObject_dealloc, /* tp_dealloc */ | 1419 (destructor)_mysql_ConnectionObject_dealloc, /* tp_dealloc */ |
1421 0, /*tp_print*/ | 1420 0, /*tp_print*/ |
1422 (getattrfunc)_mysql_ConnectionObject_getattr, /* tp_getattr */ | 1421 (getattrfunc)_mysql_ConnectionObject_getattr, /* tp_getattr */ |
1423 (setattrfunc)_mysql_ConnectionObject_setattr, /* tp_setattr */ | 1422 (setattrfunc)_mysql_ConnectionObject_setattr, /* tp_setattr */ |
1424 0, /*tp_compare*/ | 1423 0, /*tp_compare*/ |
1425 (reprfunc)_mysql_ConnectionObject_repr, /* tp_repr */ | 1424 (reprfunc)_mysql_ConnectionObject_repr, /* tp_repr */ |
1426 | 1425 |
1427 /* Method suites for standard classes */ | 1426 /* Method suites for standard classes */ |
1428 | 1427 |
1429 0, /* (PyNumberMethods *) tp_as_number */ | 1428 0, /* (PyNumberMethods *) tp_as_number */ |
1430 0, /* (PySequenceMethods *) tp_as_sequence */ | 1429 0, /* (PySequenceMethods *) tp_as_sequence */ |
1431 0, /* (PyMappingMethods *) tp_as_mapping */ | 1430 0, /* (PyMappingMethods *) tp_as_mapping */ |
1432 | 1431 |
1433 /* More standard operations (here for binary compatibility) */ | 1432 /* More standard operations (here for binary compatibility) */ |
1434 | 1433 |
1435 0, /* (hashfunc) tp_hash */ | 1434 0, /* (hashfunc) tp_hash */ |
1436 0, /* (ternaryfunc) tp_call */ | 1435 0, /* (ternaryfunc) tp_call */ |
1437 0, /* (reprfunc) tp_str */ | 1436 0, /* (reprfunc) tp_str */ |
1438 0, /* (getattrofunc) tp_getattro */ | 1437 0, /* (getattrofunc) tp_getattro */ |
1439 0, /* (setattrofunc) tp_setattro */ | 1438 0, /* (setattrofunc) tp_setattro */ |
1440 | 1439 |
1441 /* Functions to access object as input/output buffer */ | 1440 /* Functions to access object as input/output buffer */ |
1442 0, /* (PyBufferProcs *) tp_as_buffer */ | 1441 0, /* (PyBufferProcs *) tp_as_buffer */ |
1443 | 1442 |
1444 /* Flags to define presence of optional/expanded features */ | 1443 /* Flags to define presence of optional/expanded features */ |
1445 #if PY_VERSION_HEX < 0x02020000 | |
1446 Py_TPFLAGS_DEFAULT, /* (long) tp_flags */ | |
1447 #else | |
1448 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, | 1444 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, |
1449 #endif | 1445 |
1450 _mysql_connect__doc__, /* (char *) tp_doc Documentation string */ | 1446 _mysql_connect__doc__, /* (char *) tp_doc Documentation string */ |
1451 #if PY_VERSION_HEX >= 0x02000000 | 1447 |
1452 /* Assigned meaning in release 2.0 */ | |
1453 #if PY_VERSION_HEX >= 0x02020000 | |
1454 /* call function for all accessible objects */ | 1448 /* call function for all accessible objects */ |
1455 (traverseproc) _mysql_ConnectionObject_traverse, /* tp_traverse */ | 1449 (traverseproc)_mysql_ConnectionObject_traverse, /* tp_traverse */ |
1456 | 1450 |
1457 /* delete references to contained objects */ | 1451 /* delete references to contained objects */ |
1458 (inquiry) _mysql_ConnectionObject_clear, /* tp_clear */ | 1452 (inquiry)_mysql_ConnectionObject_clear, /* tp_clear */ |
1459 #else | 1453 |
1460 /* not supporting pre-2.2 GC */ | |
1461 0, | |
1462 0, | |
1463 #endif | |
1464 #if PY_VERSION_HEX >= 0x02010000 | |
1465 /* Assigned meaning in release 2.1 */ | |
1466 /* rich comparisons */ | 1454 /* rich comparisons */ |
1467 0, /* (richcmpfunc) tp_richcompare */ | 1455 0, /* (richcmpfunc) tp_richcompare */ |
1468 | 1456 |
1469 /* weak reference enabler */ | 1457 /* weak reference enabler */ |
1470 0, /* (long) tp_weaklistoffset */ | 1458 0, /* (long) tp_weaklistoffset */ |
1471 #if PY_VERSION_HEX >= 0x02020000 | 1459 |
1472 /* Added in release 2.2 */ | |
1473 /* Iterators */ | 1460 /* Iterators */ |
1474 0, /* (getiterfunc) tp_iter */ | 1461 0, /* (getiterfunc) tp_iter */ |
1475 0, /* (iternextfunc) tp_iternext */ | 1462 0, /* (iternextfunc) tp_iternext */ |
1476 | 1463 |
1477 /* Attribute descriptor and subclassing stuff */ | 1464 /* Attribute descriptor and subclassing stuff */ |
1478 (struct PyMethodDef *)_mysql_ConnectionObject_methods, /* tp_methods */ | 1465 (struct PyMethodDef *)_mysql_ConnectionObject_methods, /* tp_methods */ |
1479 (MyMemberlist(*))_mysql_ConnectionObject_memberlist, /* tp_members */ | 1466 (MyMemberlist(*))_mysql_ConnectionObject_memberlist, /* tp_members */ |
1480 0, /* (struct getsetlist *) tp_getset; */ | 1467 0, /* (struct getsetlist *) tp_getset; */ |
1481 0, /* (struct _typeobject *) tp_base; */ | 1468 0, /* (struct _typeobject *) tp_base; */ |
1484 0, /* (descrsetfunc) tp_descr_set */ | 1471 0, /* (descrsetfunc) tp_descr_set */ |
1485 0, /* (long) tp_dictoffset */ | 1472 0, /* (long) tp_dictoffset */ |
1486 (initproc)_mysql_ConnectionObject_Initialize, /* tp_init */ | 1473 (initproc)_mysql_ConnectionObject_Initialize, /* tp_init */ |
1487 NULL, /* tp_alloc */ | 1474 NULL, /* tp_alloc */ |
1488 NULL, /* tp_new */ | 1475 NULL, /* tp_new */ |
1489 NULL, /* tp_free Low-level free-memory routine */ | 1476 NULL, /* tp_free Low-level free-memory routine */ |
1490 0, /* (PyObject *) tp_bases */ | 1477 0, /* (PyObject *) tp_bases */ |
1491 0, /* (PyObject *) tp_mro method resolution order */ | 1478 0, /* (PyObject *) tp_mro method resolution order */ |
1492 0, /* (PyObject *) tp_defined */ | 1479 0, /* (PyObject *) tp_defined */ |
1493 #endif /* python 2.2 */ | 1480 }; |
1494 #endif /* python 2.1 */ | |
1495 #endif /* python 2.0 */ | |
1496 } ; | |
1497 |