diff --git a/Cython/Utility/StringTools.c b/Cython/Utility/StringTools.c
index 343d02173b32f444ecabcb19382b9315eef2c743_Q3l0aG9uL1V0aWxpdHkvU3RyaW5nVG9vbHMuYw==..353a7f7f8aeacaabdafd2126280844ef27bcc032_Q3l0aG9uL1V0aWxpdHkvU3RyaW5nVG9vbHMuYw== 100644
--- a/Cython/Utility/StringTools.c
+++ b/Cython/Utility/StringTools.c
@@ -118,6 +118,7 @@
 
 //////////////////// PyUCS4InUnicode ////////////////////
 
+#if PY_VERSION_HEX < 0x03090000
 #if Py_UNICODE_SIZE == 2
 static int __Pyx_PyUnicodeBufferContainsUCS4_SP(Py_UNICODE* buffer, Py_ssize_t length, Py_UCS4 character) {
     /* handle surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds */
@@ -141,6 +142,7 @@
     }
     return 0;
 }
+#endif
 
 static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) {
 #if CYTHON_PEP393_ENABLED
@@ -154,4 +156,6 @@
         }
         return 0;
     }
+#elif PY_VERSION_HEX >= 0x03090000
+    #error Cannot use "UChar in Unicode" in Python 3.9 without PEP-393 unicode strings.
 #endif
@@ -157,4 +161,5 @@
 #endif
+#if PY_VERSION_HEX < 0x03090000
 #if Py_UNICODE_SIZE == 2
     if (unlikely(character > 65535)) {
         return __Pyx_PyUnicodeBufferContainsUCS4_SP(
@@ -170,6 +175,7 @@
             character);
 
     }
+#endif
 }