Implement PEP 393.
diff --git a/Python/getargs.c b/Python/getargs.c
index c3da368..0e7d9c4 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -546,9 +546,6 @@
 
 
 
-#define UNICODE_DEFAULT_ENCODING(arg) \
-    _PyUnicode_AsDefaultEncodedString(arg)
-
 /* Format an error message generated by convertsimple(). */
 
 static char *
@@ -611,7 +608,7 @@
 
     const char *format = *p_format;
     char c = *format++;
-    PyObject *uarg;
+    char *sarg;
 
     switch (c) {
 
@@ -838,8 +835,11 @@
     case 'C': {/* unicode char */
         int *p = va_arg(*p_va, int *);
         if (PyUnicode_Check(arg) &&
-            PyUnicode_GET_SIZE(arg) == 1)
-            *p = PyUnicode_AS_UNICODE(arg)[0];
+            PyUnicode_GET_LENGTH(arg) == 1) {
+            int kind = PyUnicode_KIND(arg);
+            void *data = PyUnicode_DATA(arg);
+            *p = PyUnicode_READ(kind, data, 0);
+        }
         else
             return converterr("a unicode character", arg, msgbuf, bufsize);
         break;
@@ -889,13 +889,12 @@
             if (c == 'z' && arg == Py_None)
                 PyBuffer_FillInfo(p, NULL, NULL, 0, 1, 0);
             else if (PyUnicode_Check(arg)) {
-                uarg = UNICODE_DEFAULT_ENCODING(arg);
-                if (uarg == NULL)
+                Py_ssize_t len;
+                sarg = PyUnicode_AsUTF8AndSize(arg, &len);
+                if (sarg == NULL)
                     return converterr(CONV_UNICODE,
                                       arg, msgbuf, bufsize);
-                PyBuffer_FillInfo(p, arg,
-                                  PyBytes_AS_STRING(uarg), PyBytes_GET_SIZE(uarg),
-                                  1, 0);
+                PyBuffer_FillInfo(p, arg, sarg, len, 1, 0);
             }
             else { /* any buffer-like object */
                 char *buf;
@@ -918,12 +917,13 @@
                 STORE_SIZE(0);
             }
             else if (PyUnicode_Check(arg)) {
-                uarg = UNICODE_DEFAULT_ENCODING(arg);
-                if (uarg == NULL)
+                Py_ssize_t len;
+                sarg = PyUnicode_AsUTF8AndSize(arg, &len);
+                if (sarg == NULL)
                     return converterr(CONV_UNICODE,
                                       arg, msgbuf, bufsize);
-                *p = PyBytes_AS_STRING(uarg);
-                STORE_SIZE(PyBytes_GET_SIZE(uarg));
+                *p = sarg;
+                STORE_SIZE(len);
             }
             else { /* any buffer-like object */
                 /* XXX Really? */
@@ -937,22 +937,22 @@
         } else {
             /* "s" or "z" */
             char **p = va_arg(*p_va, char **);
-            uarg = NULL;
+            Py_ssize_t len;
+            sarg = NULL;
 
             if (c == 'z' && arg == Py_None)
                 *p = NULL;
             else if (PyUnicode_Check(arg)) {
-                uarg = UNICODE_DEFAULT_ENCODING(arg);
-                if (uarg == NULL)
+                sarg = PyUnicode_AsUTF8AndSize(arg, &len);
+                if (sarg == NULL)
                     return converterr(CONV_UNICODE,
                                       arg, msgbuf, bufsize);
-                *p = PyBytes_AS_STRING(uarg);
+                *p = sarg;
             }
             else
                 return converterr(c == 'z' ? "str or None" : "str",
                                   arg, msgbuf, bufsize);
-            if (*p != NULL && uarg != NULL &&
-                (Py_ssize_t) strlen(*p) != PyBytes_GET_SIZE(uarg))
+            if (*p != NULL && sarg != NULL && (Py_ssize_t) strlen(*p) != len)
                 return converterr(
                     c == 'z' ? "str without null bytes or None"
                              : "str without null bytes",
@@ -976,6 +976,8 @@
             }
             else if (PyUnicode_Check(arg)) {
                 *p = PyUnicode_AS_UNICODE(arg);
+                if (*p == NULL)
+                    RETURN_ERR_OCCURRED;
                 STORE_SIZE(PyUnicode_GET_SIZE(arg));
             }
             else
@@ -987,6 +989,8 @@
                 *p = NULL;
             else if (PyUnicode_Check(arg)) {
                 *p = PyUnicode_AS_UNICODE(arg);
+                if (*p == NULL)
+                    RETURN_ERR_OCCURRED;
                 if (Py_UNICODE_strlen(*p) != PyUnicode_GET_SIZE(arg))
                     return converterr(
                         "str without null character or None",