Issue #3236: Return small longs from PyLong_FromString.
diff --git a/Objects/longobject.c b/Objects/longobject.c
index d1c27e6..2c684cb 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1981,6 +1981,14 @@
 		goto onError;
 	if (pend)
 		*pend = str;
+	long_normalize(z);
+	if (ABS(Py_SIZE(z)) <= 1) {
+		long res = MEDIUM_VALUE(z);
+		if (-NSMALLPOSINTS <= res && res <= NSMALLPOSINTS) {
+			Py_DECREF(z);
+			return PyLong_FromLong(res);
+		}
+	}
 	return (PyObject *) z;
 
  onError: