Hi, I'm working on supporting Python3 for cvs2gitdump and tested py3-rcsparse. It's needed to be done following 2 things.
- Fix rcsparse to accept a str as an argument for sym2rev() or revs[] by using PyUnicode_AsUTF8AndSize(). The str is converted into an UTF-8 encoded byte array. This fixes "print s['RELENG_4']" test. - Use a bytes object for the result of "log" or "checkout" instead of a str object since it is needed to keep the original encoding (utf-8, latin-1, euc-jp and so on). ok? As for cvs2gitdump, it already working with Python3 and I'm testing it. https://github.com/yasuoka/cvs2gitdump/tree/WIP Index: devel/py-rcsparse/Makefile =================================================================== RCS file: /disk/cvs/openbsd/ports/devel/py-rcsparse/Makefile,v retrieving revision 1.21 diff -u -p -r1.21 Makefile --- devel/py-rcsparse/Makefile 16 Jan 2021 13:56:09 -0000 1.21 +++ devel/py-rcsparse/Makefile 15 Feb 2021 09:59:13 -0000 @@ -8,7 +8,7 @@ GH_COMMIT= 206bca0b90f5780815c0b6c6cbcc DISTNAME= rcsparse-20151027 PKGNAME= py-${DISTNAME} -REVISION= 0 +REVISION= 1 CATEGORIES= devel Index: devel/py-rcsparse/patches/patch-py-rcsparse_c =================================================================== RCS file: /disk/cvs/openbsd/ports/devel/py-rcsparse/patches/patch-py-rcsparse_c,v retrieving revision 1.3 diff -u -p -r1.3 patch-py-rcsparse_c --- devel/py-rcsparse/patches/patch-py-rcsparse_c 16 Jan 2021 13:56:09 -0000 1.3 +++ devel/py-rcsparse/patches/patch-py-rcsparse_c 15 Feb 2021 09:58:46 -0000 @@ -3,21 +3,27 @@ $OpenBSD: patch-py-rcsparse_c,v 1.3 2021 Index: py-rcsparse.c --- py-rcsparse.c.orig +++ py-rcsparse.c -@@ -25,6 +25,13 @@ +@@ -25,6 +25,19 @@ #include "rcsparse.h" +#if PY_MAJOR_VERSION >= 3 -+#define PyString_AsStringAndSize PyBytes_AsStringAndSize ++#define PyString_AsStringAndSize _PyUnicode_AsUTF8AndSize +#define PyString_CheckExact PyUnicode_CheckExact +#define PyString_FromString PyUnicode_FromString +#define PyString_FromStringAndSize PyUnicode_FromStringAndSize +#endif + ++static void ++_PyUnicode_AsUTF8AndSize(PyObject *obj, char **strp, Py_ssize_t *sizep) ++{ ++ *strp = PyUnicode_AsUTF8AndSize(obj, sizep); ++} ++ static PyObject * rcstoken2pystr(struct rcstoken *tok) { -@@ -124,7 +131,11 @@ rcsrev2py(struct rcsrev *rev) +@@ -124,7 +137,11 @@ rcsrev2py(struct rcsrev *rev) return Py_BuildValue("NNNNNNN", rcstoken2pystr(rev->rev), @@ -29,7 +35,7 @@ Index: py-rcsparse.c rcstoken2pystr(rev->author), rcstoken2pystr(rev->state), rcstoklist2py(&rev->branches), -@@ -275,7 +286,7 @@ static void +@@ -275,7 +292,7 @@ static void pyrcsrevtree_dealloc(struct pyrcsrevtree *self) { Py_DECREF((PyObject *)self->pyrcs); @@ -38,7 +44,7 @@ Index: py-rcsparse.c } static PyMappingMethods pyrcsrevtree_mapmethods = { -@@ -300,7 +311,7 @@ static PyMethodDef pyrcsrevtree_methods[] = { +@@ -300,7 +317,7 @@ static PyMethodDef pyrcsrevtree_methods[] = { }; static PyTypeObject pyrcsrevtree_type = { @@ -47,7 +53,7 @@ Index: py-rcsparse.c .tp_name= "rcsparse.rcsrevtree", .tp_basicsize= sizeof(struct pyrcsrevtree), .tp_dealloc= (destructor)pyrcsrevtree_dealloc, -@@ -496,7 +507,7 @@ static void +@@ -496,7 +513,7 @@ static void pyrcstokmap_dealloc(struct pyrcstokmap *self) { Py_DECREF((PyObject *)self->pyrcs); @@ -56,7 +62,7 @@ Index: py-rcsparse.c } static PyMappingMethods pyrcstokmap_mapmethods = { -@@ -521,7 +532,7 @@ static PyMethodDef pyrcstokmap_methods[] = { +@@ -521,7 +538,7 @@ static PyMethodDef pyrcstokmap_methods[] = { }; static PyTypeObject pyrcstokmap_type = { @@ -65,7 +71,31 @@ Index: py-rcsparse.c .tp_name= "rcsparse.rcstokmap", .tp_basicsize= sizeof(struct pyrcstokmap), .tp_dealloc= (destructor)pyrcstokmap_dealloc, -@@ -720,7 +731,7 @@ pyrcsfile_dealloc(struct pyrcsfile *self) +@@ -645,7 +662,11 @@ pyrcsfile_checkout(struct pyrcsfile *self, PyObject *a + if (buf == NULL) + return PyErr_Format(PyExc_RuntimeError, "Error parsing"); + ++#if PY_MAJOR_VERSION >= 3 ++ o = PyBytes_FromStringAndSize(buf, len); ++#else + o = PyString_FromStringAndSize(buf, len); ++#endif + free(buf); + return o; + } +@@ -664,7 +685,11 @@ pyrcsfile_getlog(struct pyrcsfile *self, PyObject *arg + if (buf == NULL) + return PyErr_Format(PyExc_RuntimeError, "Error parsing"); + ++#if PY_MAJOR_VERSION >= 3 ++ o = PyBytes_FromString(buf); ++#else + o = PyString_FromString(buf); ++#endif + free(buf); + return o; + } +@@ -720,7 +745,7 @@ pyrcsfile_dealloc(struct pyrcsfile *self) if (self->rcs != NULL) rcsclose(self->rcs); @@ -74,7 +104,7 @@ Index: py-rcsparse.c } static PyGetSetDef pyrcsfile_getseters[] = { -@@ -761,21 +772,48 @@ static PyMethodDef pyrcsparse_methods[] = { +@@ -761,21 +786,48 @@ static PyMethodDef pyrcsparse_methods[] = { {NULL} }; @@ -127,7 +157,7 @@ Index: py-rcsparse.c Py_INCREF(&pyrcsfile_type); PyModule_AddObject(m, "rcsfile", (PyObject *)&pyrcsfile_type); -@@ -783,4 +821,8 @@ initrcsparse(void) +@@ -783,4 +835,8 @@ initrcsparse(void) PyModule_AddObject(m, "rcstokmap", (PyObject *)&pyrcstokmap_type); Py_INCREF(&pyrcsrevtree_type); PyModule_AddObject(m, "rcsrevtree", (PyObject *)&pyrcsrevtree_type); Index: devel/py-rcsparse/patches/patch-testmodule_py =================================================================== RCS file: /disk/cvs/openbsd/ports/devel/py-rcsparse/patches/patch-testmodule_py,v retrieving revision 1.1 diff -u -p -r1.1 patch-testmodule_py --- devel/py-rcsparse/patches/patch-testmodule_py 16 Jan 2021 13:56:09 -0000 1.1 +++ devel/py-rcsparse/patches/patch-testmodule_py 15 Feb 2021 09:58:46 -0000 @@ -3,16 +3,16 @@ $OpenBSD: patch-testmodule_py,v 1.1 2021 Index: testmodule.py --- testmodule.py.orig +++ testmodule.py -@@ -1,11 +1,10 @@ +@@ -1,5 +1,4 @@ import rcsparse -import md5 f=rcsparse.rcsfile('test,v') print f.head - print f.branch - s=f.symbols --print s['RELENG_4'] -+#how to convert? print s['RELENG_4'] - print s.items() +@@ -10,4 +9,5 @@ print s.items() r=f.revs i=r.items() + print i +-print f.getlog(f.sym2rev('RELENG_4')) ++print f.getlog(f.sym2rev('RELENG_4')).decode('ascii') ++print '1.1' in r