Thankfully this was a lot easier than tracing hiwire keys. 

I located one actual leak: if an error is thrown during `to_js` it would forget to free `proxies`. Other than that, I fixed a few "dumb leaks" in `api.js` where we leak the methods like `eval_code` or `find_imports`. So the code was already in surprisingly good shape in this way.

It's still possible that we leak some Python objects somehow, but this is as good as we can do for systematic checks short of compiling Python itself with `TRACE_MALLOC`.
Eliminate pyproxy leaks. Thankfully this was a lot easier than tracing hiwire keys. 

I located one actual leak: if an error is thrown during `to_js` it would forget to free `proxies`. Other than that, I fixed a few "dumb leaks" in `api.js` where we leak the methods like `eval_code` or `find_imports`. So the code was already in surprisingly good shape in this way.

It's still possible that we leak some Python objects somehow, but this is as good as we can do for systematic checks short of compiling Python itself with `TRACE_MALLOC`.
#ifndef JS2PYTHON_H
#define JS2PYTHON_H

/**
 * Translate Javascript objects to Python objects.
 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "hiwire.h"

/** Convert a Javascript object to a Python object.
 *  \param x The Javascript object.
 *  \return The Python object. New reference. If NULL, a Python exception
 *    occurred during the conversion, and the Python exception API should be
 *    used to obtain the exception.
 */
PyObject*
js2python(JsRef x);

PyObject*
js2python_convert(JsRef x, int depth);

/** Initialize any global variables used by this module. */
int
js2python_init();

#endif /* JS2PYTHON_H */

#ifndef JS2PYTHON_H
#define JS2PYTHON_H

/**
 * Translate Javascript objects to Python objects.
 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "hiwire.h"

/** Convert a Javascript object to a Python object.
 *  \param x The Javascript object.
 *  \return The Python object. New reference. If NULL, a Python exception
 *    occurred during the conversion, and the Python exception API should be
 *    used to obtain the exception.
 */
PyObject*
js2python(JsRef x);

PyObject*
js2python_convert(JsRef x, int depth);

/** Initialize any global variables used by this module. */
int
js2python_init();

#endif /* JS2PYTHON_H */
