@@ -109,15 +109,18 @@ static bool ApplyPreconnAttrs(HDBC hdbc, SQLINTEGER ikey, PyObject *value, char
109109
110110 if (PyLong_Check (value))
111111 {
112- if (_PyLong_Sign (value) >= 0 )
112+ unsigned long long uval = PyLong_AsUnsignedLongLong (value);
113+ if (PyErr_Occurred ())
113114 {
114- ivalue = (SQLPOINTER )PyLong_AsUnsignedLong (value);
115- vallen = SQL_IS_UINTEGER ;
116- } else
117- {
118- ivalue = (SQLPOINTER )PyLong_AsLong (value);
115+ PyErr_Clear ();
116+ ivalue = (SQLPOINTER )PyLong_AsLongLong (value);
119117 vallen = SQL_IS_INTEGER ;
120118 }
119+ else
120+ {
121+ ivalue = (SQLPOINTER )uval;
122+ vallen = SQL_IS_UINTEGER ;
123+ }
121124 }
122125 else if (PyByteArray_Check (value))
123126 {
@@ -377,9 +380,8 @@ static char conv_clear_doc[] =
377380 " clear_output_converters() --> None\n\n "
378381 " Remove all output converter functions." ;
379382
380- static PyObject* Connection_conv_clear (PyObject* self, PyObject* args)
383+ static PyObject* Connection_conv_clear (PyObject* self, PyObject* /* args (unused) */ )
381384{
382- UNUSED (args);
383385 Connection* cnxn = (Connection*)self;
384386 Py_XDECREF (cnxn->map_sqltype_to_converter );
385387 cnxn->map_sqltype_to_converter = 0 ;
@@ -445,10 +447,8 @@ static char close_doc[] =
445447 " Note that closing a connection without committing the changes first will cause\n "
446448 " an implicit rollback to be performed." ;
447449
448- static PyObject* Connection_close (PyObject* self, PyObject* args)
450+ static PyObject* Connection_close (PyObject* self, PyObject* /* args (unused) */ )
449451{
450- UNUSED (args);
451-
452452 Connection* cnxn = Connection_Validate (self);
453453 if (!cnxn)
454454 return 0 ;
@@ -458,10 +458,8 @@ static PyObject* Connection_close(PyObject* self, PyObject* args)
458458 Py_RETURN_NONE;
459459}
460460
461- static PyObject* Connection_cursor (PyObject* self, PyObject* args)
461+ static PyObject* Connection_cursor (PyObject* self, PyObject* /* args (unused) */ )
462462{
463- UNUSED (args);
464-
465463 Connection* cnxn = Connection_Validate (self);
466464 if (!cnxn)
467465 return 0 ;
@@ -759,10 +757,8 @@ PyObject* Connection_endtrans(Connection* cnxn, SQLSMALLINT type)
759757 Py_RETURN_NONE;
760758}
761759
762- static PyObject* Connection_commit (PyObject* self, PyObject* args)
760+ static PyObject* Connection_commit (PyObject* self, PyObject* /* args (unused) */ )
763761{
764- UNUSED (args);
765-
766762 Connection* cnxn = Connection_Validate (self);
767763 if (!cnxn)
768764 return 0 ;
@@ -772,10 +768,8 @@ static PyObject* Connection_commit(PyObject* self, PyObject* args)
772768 return Connection_endtrans (cnxn, SQL_COMMIT );
773769}
774770
775- static PyObject* Connection_rollback (PyObject* self, PyObject* args)
771+ static PyObject* Connection_rollback (PyObject* self, PyObject* /* args (unused) */ )
776772{
777- UNUSED (args);
778-
779773 Connection* cnxn = Connection_Validate (self);
780774 if (!cnxn)
781775 return 0 ;
@@ -810,10 +804,8 @@ static char getinfo_doc[] =
810804 " Calls SQLGetInfo, passing `type`, and returns the result formatted as a Python object." ;
811805
812806
813- PyObject* Connection_getautocommit (PyObject* self, void * closure)
807+ PyObject* Connection_getautocommit (PyObject* self, void * /* closure (unused) */ )
814808{
815- UNUSED (closure);
816-
817809 Connection* cnxn = Connection_Validate (self);
818810 if (!cnxn)
819811 return 0 ;
@@ -823,10 +815,8 @@ PyObject* Connection_getautocommit(PyObject* self, void* closure)
823815 return result;
824816}
825817
826- static int Connection_setautocommit (PyObject* self, PyObject* value, void * closure)
818+ static int Connection_setautocommit (PyObject* self, PyObject* value, void * /* closure (unused) */ )
827819{
828- UNUSED (closure);
829-
830820 Connection* cnxn = Connection_Validate (self);
831821 if (!cnxn)
832822 return -1 ;
@@ -854,9 +844,8 @@ static int Connection_setautocommit(PyObject* self, PyObject* value, void* closu
854844}
855845
856846
857- static PyObject* Connection_getclosed (PyObject* self, void * closure)
847+ static PyObject* Connection_getclosed (PyObject* self, void * /* closure (unused) */ )
858848{
859- UNUSED (closure);
860849 Connection* cnxn;
861850
862851 if (self == 0 || !Connection_Check (self))
@@ -876,10 +865,8 @@ static PyObject* Connection_getclosed(PyObject* self, void* closure)
876865}
877866
878867
879- static PyObject* Connection_getsearchescape (PyObject* self, void * closure)
868+ static PyObject* Connection_getsearchescape (PyObject* self, void * /* closure (unused) */ )
880869{
881- UNUSED (closure);
882-
883870 Connection* cnxn = (Connection*)self;
884871
885872 if (!cnxn->searchescape )
@@ -901,21 +888,17 @@ static PyObject* Connection_getsearchescape(PyObject* self, void* closure)
901888 return cnxn->searchescape ;
902889}
903890
904- static PyObject* Connection_getmaxwrite (PyObject* self, void * closure)
891+ static PyObject* Connection_getmaxwrite (PyObject* self, void * /* closure (unused) */ )
905892{
906- UNUSED (closure);
907-
908893 Connection* cnxn = Connection_Validate (self);
909894 if (!cnxn)
910895 return 0 ;
911896
912897 return PyLong_FromSsize_t (cnxn->maxwrite );
913898}
914899
915- static int Connection_setmaxwrite (PyObject* self, PyObject* value, void * closure)
900+ static int Connection_setmaxwrite (PyObject* self, PyObject* value, void * /* closure (unused) */ )
916901{
917- UNUSED (closure);
918-
919902 Connection* cnxn = Connection_Validate (self);
920903 if (!cnxn)
921904 return -1 ;
@@ -943,21 +926,17 @@ static int Connection_setmaxwrite(PyObject* self, PyObject* value, void* closure
943926}
944927
945928
946- static PyObject* Connection_gettimeout (PyObject* self, void * closure)
929+ static PyObject* Connection_gettimeout (PyObject* self, void * /* closure (unused) */ )
947930{
948- UNUSED (closure);
949-
950931 Connection* cnxn = Connection_Validate (self);
951932 if (!cnxn)
952933 return 0 ;
953934
954935 return PyLong_FromLong (cnxn->timeout );
955936}
956937
957- static int Connection_settimeout (PyObject* self, PyObject* value, void * closure)
938+ static int Connection_settimeout (PyObject* self, PyObject* value, void * /* closure (unused) */ )
958939{
959- UNUSED (closure);
960-
961940 Connection* cnxn = Connection_Validate (self);
962941 if (!cnxn)
963942 return -1 ;
@@ -1328,9 +1307,8 @@ static PyObject* Connection_setdecoding(PyObject* self, PyObject* args, PyObject
13281307
13291308
13301309static char enter_doc[] = " __enter__() -> self." ;
1331- static PyObject* Connection_enter (PyObject* self, PyObject* args)
1310+ static PyObject* Connection_enter (PyObject* self, PyObject* /* args (unused) */ )
13321311{
1333- UNUSED (args);
13341312 Py_INCREF (self);
13351313 return self;
13361314}
0 commit comments