shithub: aubio

Download patch

ref: ade36e60bf5e7041c3f8e2ddf4f507fb66e10d2e
parent: 7ffb55476b0d6d4db123158186aed7ea72492915
author: Paul Brossier <piem@piem.org>
date: Mon Apr 18 19:23:08 EDT 2016

python/lib/gen_pyobject.py: prepare for python3 (see #33)

--- a/python/lib/gen_pyobject.py
+++ b/python/lib/gen_pyobject.py
@@ -150,7 +150,7 @@
 aubiovecfrompyobj = {
     'fvec_t*': 'PyAubio_ArrayToCFvec',
     'cvec_t*': 'PyAubio_ArrayToCCvec',
-    'uint_t': '(uint_t)PyInt_AsLong',
+    'uint_t': '(uint_t)PyLong_AsLong',
 }
 
 # aubio to python
@@ -158,8 +158,8 @@
     'fvec_t*': 'PyAubio_CFvecToArray',
     'cvec_t*': 'PyAubio_CCvecToPyCvec',
     'smpl_t': 'PyFloat_FromDouble',
-    'uint_t*': 'PyInt_FromLong',
-    'uint_t': 'PyInt_FromLong',
+    'uint_t*': 'PyLong_FromLong',
+    'uint_t': 'PyLong_FromLong',
 }
 
 def gen_new_init(newfunc, name):
@@ -171,7 +171,7 @@
         selfparams = '' 
     # "param1", "param2", "param3"
     paramnames = ", ".join(["\""+p['name']+"\"" for p in newparams])
-    pyparams = "".join(map(lambda p: aubio2pytypes[p['type']], newparams))
+    pyparams = "".join([aubio2pytypes[p['type']] for p in newparams])
     paramrefs = ", ".join(["&" + p['name'] for p in newparams])
     s = """\
 // WARNING: this file is generated, DO NOT EDIT
@@ -288,7 +288,7 @@
         inputdefs += "  PyObject * " + p['name'] + "_obj;\n"
 
     inputvecs = "  /* input vectors prototypes */\n  "
-    inputvecs += "\n  ".join(map(lambda p: p['type'] + ' ' + p['name'] + ";", inputparams))
+    inputvecs += "\n  ".join([ p['type'] + ' ' + p['name'] + ";" for p in inputparams])
 
     parseinput = "  /* input vectors parsing */\n  "
     for p in inputparams:
@@ -362,7 +362,7 @@
 
     n_param = len(doparams)
 
-    if name in param_numbers.keys():
+    if name in list(param_numbers.keys()):
       n_input_param, n_output_param = param_numbers[name]
     else:
       n_input_param, n_output_param = 1, n_param - 1