@@ -159,8 +159,7 @@ unicodedata_UCD_decimal_impl(PyObject *self, int chr,
159159 return NULL ;
160160 }
161161 else {
162- Py_INCREF (default_value );
163- return default_value ;
162+ return Py_NewRef (default_value );
164163 }
165164 }
166165 return PyLong_FromLong (rc );
@@ -194,8 +193,7 @@ unicodedata_UCD_digit_impl(PyObject *self, int chr, PyObject *default_value)
194193 return NULL ;
195194 }
196195 else {
197- Py_INCREF (default_value );
198- return default_value ;
196+ return Py_NewRef (default_value );
199197 }
200198 }
201199 return PyLong_FromLong (rc );
@@ -246,8 +244,7 @@ unicodedata_UCD_numeric_impl(PyObject *self, int chr,
246244 return NULL ;
247245 }
248246 else {
249- Py_INCREF (default_value );
250- return default_value ;
247+ return Py_NewRef (default_value );
251248 }
252249 }
253250 return PyFloat_FromDouble (rc );
@@ -917,8 +914,7 @@ unicodedata_UCD_is_normalized_impl(PyObject *self, PyObject *form,
917914 result = (m == YES ) ? Py_True : Py_False ;
918915 }
919916
920- Py_INCREF (result );
921- return result ;
917+ return Py_NewRef (result );
922918}
923919
924920
@@ -943,39 +939,34 @@ unicodedata_UCD_normalize_impl(PyObject *self, PyObject *form,
943939 if (PyUnicode_GET_LENGTH (input ) == 0 ) {
944940 /* Special case empty input strings, since resizing
945941 them later would cause internal errors. */
946- Py_INCREF (input );
947- return input ;
942+ return Py_NewRef (input );
948943 }
949944
950945 if (PyUnicode_CompareWithASCIIString (form , "NFC" ) == 0 ) {
951946 if (is_normalized_quickcheck (self , input ,
952947 true, false, true) == YES ) {
953- Py_INCREF (input );
954- return input ;
948+ return Py_NewRef (input );
955949 }
956950 return nfc_nfkc (self , input , 0 );
957951 }
958952 if (PyUnicode_CompareWithASCIIString (form , "NFKC" ) == 0 ) {
959953 if (is_normalized_quickcheck (self , input ,
960954 true, true, true) == YES ) {
961- Py_INCREF (input );
962- return input ;
955+ return Py_NewRef (input );
963956 }
964957 return nfc_nfkc (self , input , 1 );
965958 }
966959 if (PyUnicode_CompareWithASCIIString (form , "NFD" ) == 0 ) {
967960 if (is_normalized_quickcheck (self , input ,
968961 false, false, true) == YES ) {
969- Py_INCREF (input );
970- return input ;
962+ return Py_NewRef (input );
971963 }
972964 return nfd_nfkd (self , input , 0 );
973965 }
974966 if (PyUnicode_CompareWithASCIIString (form , "NFKD" ) == 0 ) {
975967 if (is_normalized_quickcheck (self , input ,
976968 false, true, true) == YES ) {
977- Py_INCREF (input );
978- return input ;
969+ return Py_NewRef (input );
979970 }
980971 return nfd_nfkd (self , input , 1 );
981972 }
@@ -1370,8 +1361,7 @@ unicodedata_UCD_name_impl(PyObject *self, int chr, PyObject *default_value)
13701361 return NULL ;
13711362 }
13721363 else {
1373- Py_INCREF (default_value );
1374- return default_value ;
1364+ return Py_NewRef (default_value );
13751365 }
13761366 }
13771367
0 commit comments