mercurial/manifest.c
changeset 30097 3bf4b762537e
parent 30079 84debea79903
child 30168 1a327889c13c
--- a/mercurial/manifest.c	Sun Oct 02 17:31:32 2016 +0900
+++ b/mercurial/manifest.c	Sat Oct 08 21:57:55 2016 +0200
@@ -56,10 +56,10 @@
 	}
 	if (l->hash_suffix != '\0') {
 		char newhash[21];
-		memcpy(newhash, PyString_AsString(hash), 20);
+		memcpy(newhash, PyBytes_AsString(hash), 20);
 		Py_DECREF(hash);
 		newhash[20] = l->hash_suffix;
-		hash = PyString_FromStringAndSize(newhash, 21);
+		hash = PyBytes_FromStringAndSize(newhash, 21);
 	}
 	return hash;
 }
@@ -79,7 +79,7 @@
 
 	if (!hash)
 		return NULL;
-	flags = PyString_FromStringAndSize(s + hplen - 1, flen);
+	flags = PyBytes_FromStringAndSize(s + hplen - 1, flen);
 	if (!flags) {
 		Py_DECREF(hash);
 		return NULL;
@@ -144,7 +144,7 @@
 	if (!PyArg_ParseTuple(args, "S", &pydata)) {
 		return -1;
 	}
-	err = PyString_AsStringAndSize(pydata, &data, &len);
+	err = PyBytes_AsStringAndSize(pydata, &data, &len);
 
 	self->dirty = false;
 	if (err == -1)
@@ -238,10 +238,10 @@
 		goto done;
 	}
 	pl = pathlen(l);
-	path = PyString_FromStringAndSize(l->start, pl);
+	path = PyBytes_FromStringAndSize(l->start, pl);
 	hash = nodeof(l);
 	consumed = pl + 41;
-	flags = PyString_FromStringAndSize(l->start + consumed,
+	flags = PyBytes_FromStringAndSize(l->start + consumed,
 					   l->len - consumed - 1);
 	if (!path || !hash || !flags) {
 		goto done;
@@ -300,7 +300,7 @@
 		return NULL;
 	}
 	pl = pathlen(l);
-	return PyString_FromStringAndSize(l->start, pl);
+	return PyBytes_FromStringAndSize(l->start, pl);
 }
 
 #ifdef IS_PY3K
@@ -398,12 +398,12 @@
 {
 	line needle;
 	line *hit;
-	if (!PyString_Check(key)) {
+	if (!PyBytes_Check(key)) {
 		PyErr_Format(PyExc_TypeError,
 			     "getitem: manifest keys must be a string.");
 		return NULL;
 	}
-	needle.start = PyString_AsString(key);
+	needle.start = PyBytes_AsString(key);
 	hit = bsearch(&needle, self->lines, self->numlines, sizeof(line),
 		      &linecmp);
 	if (!hit || hit->deleted) {
@@ -417,12 +417,12 @@
 {
 	line needle;
 	line *hit;
-	if (!PyString_Check(key)) {
+	if (!PyBytes_Check(key)) {
 		PyErr_Format(PyExc_TypeError,
 			     "delitem: manifest keys must be a string.");
 		return -1;
 	}
-	needle.start = PyString_AsString(key);
+	needle.start = PyBytes_AsString(key);
 	hit = bsearch(&needle, self->lines, self->numlines, sizeof(line),
 		      &linecmp);
 	if (!hit || hit->deleted) {
@@ -486,7 +486,7 @@
 	char *dest;
 	int i;
 	line new;
-	if (!PyString_Check(key)) {
+	if (!PyBytes_Check(key)) {
 		PyErr_Format(PyExc_TypeError,
 			     "setitem: manifest keys must be a string.");
 		return -1;
@@ -499,17 +499,17 @@
 			     "Manifest values must be a tuple of (node, flags).");
 		return -1;
 	}
-	if (PyString_AsStringAndSize(key, &path, &plen) == -1) {
+	if (PyBytes_AsStringAndSize(key, &path, &plen) == -1) {
 		return -1;
 	}
 
 	pyhash = PyTuple_GetItem(value, 0);
-	if (!PyString_Check(pyhash)) {
+	if (!PyBytes_Check(pyhash)) {
 		PyErr_Format(PyExc_TypeError,
 			     "node must be a 20-byte string");
 		return -1;
 	}
-	hlen = PyString_Size(pyhash);
+	hlen = PyBytes_Size(pyhash);
 	/* Some parts of the codebase try and set 21 or 22
 	 * byte "hash" values in order to perturb things for
 	 * status. We have to preserve at least the 21st
@@ -521,15 +521,15 @@
 			     "node must be a 20-byte string");
 		return -1;
 	}
-	hash = PyString_AsString(pyhash);
+	hash = PyBytes_AsString(pyhash);
 
 	pyflags = PyTuple_GetItem(value, 1);
-	if (!PyString_Check(pyflags) || PyString_Size(pyflags) > 1) {
+	if (!PyBytes_Check(pyflags) || PyBytes_Size(pyflags) > 1) {
 		PyErr_Format(PyExc_TypeError,
 			     "flags must a 0 or 1 byte string");
 		return -1;
 	}
-	if (PyString_AsStringAndSize(pyflags, &flags, &flen) == -1) {
+	if (PyBytes_AsStringAndSize(pyflags, &flags, &flen) == -1) {
 		return -1;
 	}
 	/* one null byte and one newline */
@@ -574,12 +574,12 @@
 {
 	line needle;
 	line *hit;
-	if (!PyString_Check(key)) {
+	if (!PyBytes_Check(key)) {
 		/* Our keys are always strings, so if the contains
 		 * check is for a non-string, just return false. */
 		return 0;
 	}
-	needle.start = PyString_AsString(key);
+	needle.start = PyBytes_AsString(key);
 	hit = bsearch(&needle, self->lines, self->numlines, sizeof(line),
 		      &linecmp);
 	if (!hit || hit->deleted) {
@@ -619,10 +619,10 @@
 			need += self->lines[i].len;
 		}
 	}
-	pydata = PyString_FromStringAndSize(NULL, need);
+	pydata = PyBytes_FromStringAndSize(NULL, need);
 	if (!pydata)
 		return -1;
-	data = PyString_AsString(pydata);
+	data = PyBytes_AsString(pydata);
 	if (!data) {
 		return -1;
 	}
@@ -757,7 +757,7 @@
 		return NULL;
 	}
 	listclean = (!pyclean) ? false : PyObject_IsTrue(pyclean);
-	es = PyString_FromString("");
+	es = PyBytes_FromString("");
 	if (!es) {
 		goto nomem;
 	}
@@ -797,8 +797,8 @@
 			result = linecmp(left, right);
 		}
 		key = result <= 0 ?
-			PyString_FromString(left->start) :
-			PyString_FromString(right->start);
+			PyBytes_FromString(left->start) :
+			PyBytes_FromString(right->start);
 		if (!key)
 			goto nomem;
 		if (result < 0) {