code:     static final PyObject function___new__(PyNewWrapper new_, boolean init, PyType subtype,
                                             PyObject[] args, String[] keywords) {
          ArgParser ap = new ArgParser("function", args, keywords,
                                       new String[] {"code", "globals", "name", "argdefs",
                                                     "closure"}, 0);
          PyObject code = ap.getPyObject(0);
          PyObject globals = ap.getPyObject(1);
          PyObject name = ap.getPyObject(2, Py.None);
          PyObject defaults = ap.getPyObject(3, Py.None);
          PyObject closure = ap.getPyObject(4, Py.None);
  
          if (!(code instanceof PyBaseCode)) {
              throw Py.TypeError("function() argument 1 must be code, not " +
                                 code.getType().fastGetName());
          }
          if (name != Py.None && !Py.isInstance(name, PyString.TYPE)) {
              throw Py.TypeError("arg 3 (name) must be None or string");
          }
          if (defaults != Py.None && !(defaults instanceof PyTuple)) {
              throw Py.TypeError("arg 4 (defaults) must be None or tuple");
          }
  
          PyBaseCode tcode = (PyBaseCode)code;
          int nfree = tcode.co_freevars == null ? 0 : tcode.co_freevars.length;
          if (!(closure instanceof PyTuple)) {
              if (nfree > 0 && closure == Py.None) {
                  throw Py.TypeError("arg 5 (closure) must be tuple");
              } else if (closure != Py.None) {
                  throw Py.TypeError("arg 5 (closure) must be None or tuple");
              }
          }
  
          int nclosure = closure == Py.None ? 0 : closure.__len__();
          if (nfree != nclosure) {
              throw Py.ValueError(String.format("%s requires closure of length %d, not %d",
                                                tcode.co_name, nfree, nclosure));
          }
          if (nclosure > 0) {
              for (PyObject o : ((PyTuple)closure).asIterable()) {
                  if (!(o instanceof PyCell)) {
                      throw Py.TypeError(String.format("arg 5 (closure) expected cell, found %s",
                                                       o.getType().fastGetName()));
                  }
              }
          }
  
          PyFunction function = new PyFunction(globals,
                                               defaults == Py.None
                                               ? null : ((PyTuple)defaults).getArray(),
                                               tcode, null,
                                               closure == Py.None
                                               ? null : ((PyTuple)closure).getArray());
          if (name != Py.None) {
              function.__name__ = name.toString();
          }
          return function;
      }
  
      @ExposedSet(name = "__name__")
  