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 PYTHON2JS_BUFFER_H
#define PYTHON2JS_BUFFER_H

/** Utilities to convert Python buffer objects to Javascript.
 */
// clang-format off
#define PY_SSIZE_T_CLEAN
#include "Python.h"
// clang-format on
#include "hiwire.h"

/** Convert a Python buffer object to a Javascript object.
 *
 *  \param The Python object
 *  \return The Javascript object -- might be an Error object in the case of an
 *     exception.
 */
JsRef
_python2js_buffer(PyObject* x);

errcode
python2js_buffer_init();

#endif /* PYTHON2JS_BUFFER_H */

#ifndef PYTHON2JS_BUFFER_H
#define PYTHON2JS_BUFFER_H

/** Utilities to convert Python buffer objects to Javascript.
 */
// clang-format off
#define PY_SSIZE_T_CLEAN
#include "Python.h"
// clang-format on
#include "hiwire.h"

/** Convert a Python buffer object to a Javascript object.
 *
 *  \param The Python object
 *  \return The Javascript object -- might be an Error object in the case of an
 *     exception.
 */
JsRef
_python2js_buffer(PyObject* x);

errcode
python2js_buffer_init();

#endif /* PYTHON2JS_BUFFER_H */
