Skip to content

Instantly share code, notes, and snippets.

@four0four
Created December 15, 2019 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save four0four/f4d49513f29326a552cc0b73416393c7 to your computer and use it in GitHub Desktop.
Save four0four/f4d49513f29326a552cc0b73416393c7 to your computer and use it in GitHub Desktop.
Patch to fix up urjtag python3 support
diff -Naur urjtag-2018.09.orig/bindings/python/chain.c urjtag-2018.09/bindings/python/chain.c
--- urjtag-2018.09.orig/bindings/python/chain.c 2018-09-25 14:32:40.583308869 -0700
+++ urjtag-2018.09/bindings/python/chain.c 2018-09-25 14:33:31.924518776 -0700
@@ -243,7 +243,7 @@
urj_pyc_partid (urj_pychain_t *self, PyObject *args)
{
urj_chain_t *urc = self->urchain;
- int partno;
+ unsigned int partno;
if (!PyArg_ParseTuple (args, "i", &partno))
return NULL;
diff -Naur urjtag-2018.09.orig/bindings/python/register.c urjtag-2018.09/bindings/python/register.c
--- urjtag-2018.09.orig/bindings/python/register.c 2018-09-25 14:32:40.583308869 -0700
+++ urjtag-2018.09/bindings/python/register.c 2018-09-25 14:35:10.558794872 -0700
@@ -52,9 +52,13 @@
if (self->urreg == NULL || self->inst == NULL)
snprintf (buf, 200, "<urjtag.register chain=%p invalid>", urc);
else
- snprintf (buf, 200, "<urjtag.register chain=%p reg=%s inst=%s>", urc,
+ snprintf (buf, 200, "<urjtag.register chain=%p reg=%s inst=%s>", urc,
self->urreg->name, self->inst->name);
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromString (buf);
+#else
return PyString_FromString (buf);
+#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment