Issue #5835, deprecate PyOS_ascii_formatd.

If anyone wants to clean up the documentation, feel free. It's my first documentation foray, and it's not that great.

Will port to py3k with a different strategy.
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 4f041f4..382b991 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -342,7 +342,6 @@
 format_float(char *buf, size_t buflen, PyFloatObject *v, int precision)
 {
 	register char *cp;
-	char format[32];
 	int i;
 
 	/* Subroutine for float_repr and float_print.
@@ -352,8 +351,8 @@
 	   in such cases, we append ".0" to the string. */
 
 	assert(PyFloat_Check(v));
-	PyOS_snprintf(format, 32, "%%.%ig", precision);
-	PyOS_ascii_formatd(buf, buflen, format, v->ob_fval);
+	_PyOS_double_to_string(buf, buflen, v->ob_fval, 'g', precision,
+                               0, NULL);
 	cp = buf;
 	if (*cp == '-')
 		cp++;
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 89614e6..316a271 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4332,9 +4332,6 @@
 formatfloat(char *buf, size_t buflen, int flags,
             int prec, int type, PyObject *v)
 {
-	/* fmt = '%#.' + `prec` + `type`
-	   worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/
-	char fmt[20];
 	double x;
 	x = PyFloat_AsDouble(v);
 	if (x == -1.0 && PyErr_Occurred()) {
@@ -4378,10 +4375,8 @@
 			"formatted float is too long (precision too large?)");
 		return -1;
 	}
-	PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c",
-		      (flags&F_ALT) ? "#" : "",
-		      prec, type);
-	PyOS_ascii_formatd(buf, buflen, fmt, x);
+	_PyOS_double_to_string(buf, buflen, x, type, prec,
+                            (flags&F_ALT)?Py_DTSF_ALT:0, NULL);
 	return (int)strlen(buf);
 }
 
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6edc2f8..62191ad 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -8245,11 +8245,13 @@
 }
 
 static int
-doubletounicode(Py_UNICODE *buffer, size_t len, const char *format, double x)
+doubletounicode(Py_UNICODE *buffer, size_t len, int format_code,
+                int precision, int flags, double x)
 {
     Py_ssize_t result;
 
-    PyOS_ascii_formatd((char *)buffer, len, format, x);
+    _PyOS_double_to_string((char *)buffer, len, x, format_code, precision,
+                           flags, NULL);
     result = strtounicode(buffer, (char *)buffer);
     return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
 }
@@ -8276,9 +8278,6 @@
             int type,
             PyObject *v)
 {
-    /* fmt = '%#.' + `prec` + `type`
-       worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/
-    char fmt[20];
     double x;
 
     x = PyFloat_AsDouble(v);
@@ -8320,10 +8319,8 @@
                         "formatted float is too long (precision too large?)");
         return -1;
     }
-    PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c",
-                  (flags&F_ALT) ? "#" : "",
-                  prec, type);
-    return doubletounicode(buf, buflen, fmt, x);
+    return doubletounicode(buf, buflen, type, prec,
+                           (flags&F_ALT)?Py_DTSF_ALT:0, x);
 }
 
 static PyObject*