@@ -1720,7 +1720,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
17201720/*[clinic input]
17211721_sqlite3.Connection.create_collation as pysqlite_connection_create_collation
17221722
1723- name: unicode
1723+ name: str
17241724 callback as callable: object
17251725 /
17261726
@@ -1729,61 +1729,26 @@ Creates a collation function. Non-standard.
17291729
17301730static PyObject *
17311731pysqlite_connection_create_collation_impl (pysqlite_Connection * self ,
1732- PyObject * name , PyObject * callable )
1733- /*[clinic end generated code: output=0f63b8995565ae22 input=5c3898813a776cf2]*/
1732+ const char * name ,
1733+ PyObject * callable )
1734+ /*[clinic end generated code: output=a4ceaff957fdef9a input=301647aab0f2fb1d]*/
17341735{
1735- PyObject * uppercase_name = 0 ;
1736- Py_ssize_t i , len ;
1737- _Py_IDENTIFIER (upper );
1738- const char * uppercase_name_str ;
1739- int rc ;
1740- unsigned int kind ;
1741- const void * data ;
1742-
17431736 if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
1744- goto finally ;
1745- }
1746-
1747- uppercase_name = _PyObject_CallMethodIdOneArg ((PyObject * )& PyUnicode_Type ,
1748- & PyId_upper , name );
1749- if (!uppercase_name ) {
1750- goto finally ;
1751- }
1752-
1753- if (PyUnicode_READY (uppercase_name ))
1754- goto finally ;
1755- len = PyUnicode_GET_LENGTH (uppercase_name );
1756- kind = PyUnicode_KIND (uppercase_name );
1757- data = PyUnicode_DATA (uppercase_name );
1758- for (i = 0 ; i < len ; i ++ ) {
1759- Py_UCS4 ch = PyUnicode_READ (kind , data , i );
1760- if ((ch >= '0' && ch <= '9' )
1761- || (ch >= 'A' && ch <= 'Z' )
1762- || (ch == '_' ))
1763- {
1764- continue ;
1765- } else {
1766- PyErr_SetString (self -> ProgrammingError ,
1767- "invalid character in collation name" );
1768- goto finally ;
1769- }
1737+ return NULL ;
17701738 }
17711739
1772- uppercase_name_str = PyUnicode_AsUTF8 (uppercase_name );
1773- if (!uppercase_name_str )
1774- goto finally ;
1775-
1740+ int rc ;
17761741 int flags = SQLITE_UTF8 ;
17771742 if (callable == Py_None ) {
1778- rc = sqlite3_create_collation_v2 (self -> db , uppercase_name_str , flags ,
1743+ rc = sqlite3_create_collation_v2 (self -> db , name , flags ,
17791744 NULL , NULL , NULL );
17801745 }
17811746 else {
17821747 if (!PyCallable_Check (callable )) {
17831748 PyErr_SetString (PyExc_TypeError , "parameter must be callable" );
1784- goto finally ;
1749+ return NULL ;
17851750 }
1786- rc = sqlite3_create_collation_v2 (self -> db , uppercase_name_str , flags ,
1751+ rc = sqlite3_create_collation_v2 (self -> db , name , flags ,
17871752 Py_NewRef (callable ),
17881753 & pysqlite_collation_callback ,
17891754 & _destructor );
@@ -1798,16 +1763,10 @@ pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
17981763 Py_DECREF (callable );
17991764 }
18001765 _pysqlite_seterror (self -> db );
1801- goto finally ;
1802- }
1803-
1804- finally :
1805- Py_XDECREF (uppercase_name );
1806-
1807- if (PyErr_Occurred ()) {
18081766 return NULL ;
18091767 }
1810- return Py_NewRef (Py_None );
1768+
1769+ Py_RETURN_NONE ;
18111770}
18121771
18131772/*[clinic input]
0 commit comments