Show More
@@ -156,7 +156,7 b' PyObject *encodedir(PyObject *self, PyOb' | |||
|
156 | 156 | if (!PyArg_ParseTuple(args, "O:encodedir", &pathobj)) |
|
157 | 157 | return NULL; |
|
158 | 158 | |
|
159 |
if (Py |
|
|
159 | if (PyBytes_AsStringAndSize(pathobj, &path, &len) == -1) { | |
|
160 | 160 | PyErr_SetString(PyExc_TypeError, "expected a string"); |
|
161 | 161 | return NULL; |
|
162 | 162 | } |
@@ -168,11 +168,11 b' PyObject *encodedir(PyObject *self, PyOb' | |||
|
168 | 168 | return pathobj; |
|
169 | 169 | } |
|
170 | 170 | |
|
171 |
newobj = Py |
|
|
171 | newobj = PyBytes_FromStringAndSize(NULL, newlen); | |
|
172 | 172 | |
|
173 | 173 | if (newobj) { |
|
174 |
Py |
|
|
175 |
_encodedir(Py |
|
|
174 | PyBytes_GET_SIZE(newobj)--; | |
|
175 | _encodedir(PyBytes_AS_STRING(newobj), newlen, path, | |
|
176 | 176 | len + 1); |
|
177 | 177 | } |
|
178 | 178 | |
@@ -515,9 +515,9 b' PyObject *lowerencode(PyObject *self, Py' | |||
|
515 | 515 | return NULL; |
|
516 | 516 | |
|
517 | 517 | newlen = _lowerencode(NULL, 0, path, len); |
|
518 |
ret = Py |
|
|
518 | ret = PyBytes_FromStringAndSize(NULL, newlen); | |
|
519 | 519 | if (ret) |
|
520 |
_lowerencode(Py |
|
|
520 | _lowerencode(PyBytes_AS_STRING(ret), newlen, path, len); | |
|
521 | 521 | |
|
522 | 522 | return ret; |
|
523 | 523 | } |
@@ -568,11 +568,11 b' static PyObject *hashmangle(const char *' | |||
|
568 | 568 | if (lastdot >= 0) |
|
569 | 569 | destsize += len - lastdot - 1; |
|
570 | 570 | |
|
571 |
ret = Py |
|
|
571 | ret = PyBytes_FromStringAndSize(NULL, destsize); | |
|
572 | 572 | if (ret == NULL) |
|
573 | 573 | return NULL; |
|
574 | 574 | |
|
575 |
dest = Py |
|
|
575 | dest = PyBytes_AS_STRING(ret); | |
|
576 | 576 | memcopy(dest, &destlen, destsize, "dh/", 3); |
|
577 | 577 | |
|
578 | 578 | /* Copy up to dirprefixlen bytes of each path component, up to |
@@ -638,7 +638,7 b' static PyObject *hashmangle(const char *' | |||
|
638 | 638 | memcopy(dest, &destlen, destsize, &src[lastdot], |
|
639 | 639 | len - lastdot - 1); |
|
640 | 640 | |
|
641 |
Py |
|
|
641 | PyBytes_GET_SIZE(ret) = destlen; | |
|
642 | 642 | |
|
643 | 643 | return ret; |
|
644 | 644 | } |
@@ -653,7 +653,7 b' static int sha1hash(char hash[20], const' | |||
|
653 | 653 | PyObject *shaobj, *hashobj; |
|
654 | 654 | |
|
655 | 655 | if (shafunc == NULL) { |
|
656 |
PyObject *hashlib, *name = Py |
|
|
656 | PyObject *hashlib, *name = PyBytes_FromString("hashlib"); | |
|
657 | 657 | |
|
658 | 658 | if (name == NULL) |
|
659 | 659 | return -1; |
@@ -686,14 +686,14 b' static int sha1hash(char hash[20], const' | |||
|
686 | 686 | if (hashobj == NULL) |
|
687 | 687 | return -1; |
|
688 | 688 | |
|
689 |
if (!Py |
|
|
689 | if (!PyBytes_Check(hashobj) || PyBytes_GET_SIZE(hashobj) != 20) { | |
|
690 | 690 | PyErr_SetString(PyExc_TypeError, |
|
691 | 691 | "result of digest is not a 20-byte hash"); |
|
692 | 692 | Py_DECREF(hashobj); |
|
693 | 693 | return -1; |
|
694 | 694 | } |
|
695 | 695 | |
|
696 |
memcpy(hash, Py |
|
|
696 | memcpy(hash, PyBytes_AS_STRING(hashobj), 20); | |
|
697 | 697 | Py_DECREF(hashobj); |
|
698 | 698 | return 0; |
|
699 | 699 | } |
@@ -731,7 +731,7 b' PyObject *pathencode(PyObject *self, PyO' | |||
|
731 | 731 | if (!PyArg_ParseTuple(args, "O:pathencode", &pathobj)) |
|
732 | 732 | return NULL; |
|
733 | 733 | |
|
734 |
if (Py |
|
|
734 | if (PyBytes_AsStringAndSize(pathobj, &path, &len) == -1) { | |
|
735 | 735 | PyErr_SetString(PyExc_TypeError, "expected a string"); |
|
736 | 736 | return NULL; |
|
737 | 737 | } |
@@ -747,11 +747,11 b' PyObject *pathencode(PyObject *self, PyO' | |||
|
747 | 747 | return pathobj; |
|
748 | 748 | } |
|
749 | 749 | |
|
750 |
newobj = Py |
|
|
750 | newobj = PyBytes_FromStringAndSize(NULL, newlen); | |
|
751 | 751 | |
|
752 | 752 | if (newobj) { |
|
753 |
Py |
|
|
754 |
basicencode(Py |
|
|
753 | PyBytes_GET_SIZE(newobj)--; | |
|
754 | basicencode(PyBytes_AS_STRING(newobj), newlen, path, | |
|
755 | 755 | len + 1); |
|
756 | 756 | } |
|
757 | 757 | } |
General Comments 0
You need to be logged in to leave comments.
Login now