示例#1
0
  public static void SystemExit__init__(PyObject self, PyObject[] args, String[] kwargs) {
    PyBaseException.TYPE.invoke("__init__", self, args, kwargs);
    initSlots(self);

    if (args.length == 1) {
      self.__setattr__("code", args[0]);
    } else if (args.length > 1) {
      self.__setattr__("code", new PyTuple(args));
    }
  }
示例#2
0
 public static void UnicodeTranslateError__init__(
     PyObject self, PyObject[] args, String[] kwargs) {
   PyBaseException.TYPE.invoke("__init__", self, args, kwargs);
   ArgParser ap =
       new ArgParser(
           "__init__", args, kwargs, new String[] {"object", "start", "end", "reason"}, 4);
   self.__setattr__("object", ap.getPyObjectByType(0, PyUnicode.TYPE));
   self.__setattr__("start", ap.getPyObjectByType(1, PyInteger.TYPE));
   self.__setattr__("end", ap.getPyObjectByType(2, PyInteger.TYPE));
   self.__setattr__("reason", ap.getPyObjectByType(3, PyString.TYPE));
 }
示例#3
0
 public static void UnicodeError__init__(
     PyObject self, PyObject[] args, String[] kwargs, PyType objectType) {
   ArgParser ap =
       new ArgParser(
           "__init__",
           args,
           kwargs,
           new String[] {"encoding", "object", "start", "end", "reason"},
           5);
   self.__setattr__("encoding", ap.getPyObjectByType(0, PyString.TYPE));
   self.__setattr__("object", ap.getPyObjectByType(1, objectType));
   self.__setattr__("start", ap.getPyObjectByType(2, PyInteger.TYPE));
   self.__setattr__("end", ap.getPyObjectByType(3, PyInteger.TYPE));
   self.__setattr__("reason", ap.getPyObjectByType(4, PyString.TYPE));
 }
示例#4
0
  public static void EnvironmentError__init__(PyObject self, PyObject[] args, String[] kwargs) {
    PyBaseException.TYPE.invoke("__init__", self, args, kwargs);
    initSlots(self);

    if (args.length <= 1 || args.length > 3) {
      return;
    }
    PyObject errno = args[0];
    PyObject strerror = args[1];
    self.__setattr__("errno", errno);
    self.__setattr__("strerror", strerror);
    if (args.length == 3) {
      self.__setattr__("filename", args[2]);
      self.__setattr__("args", new PyTuple(errno, strerror));
    }
  }
示例#5
0
 /**
  * Initialize all __slots__ arguments in the specified dict to None.
  *
  * @param self a PyObject dict
  */
 private static void initSlots(PyObject self) {
   for (PyObject name : self.__findattr__("__slots__").asIterable()) {
     if (!(name instanceof PyString)) {
       continue;
     }
     self.__setattr__((PyString) name, Py.None);
   }
 }
示例#6
0
  public static void SyntaxError__init__(PyObject self, PyObject[] args, String[] kwargs) {
    PyBaseException.TYPE.invoke("__init__", self, args, kwargs);
    initSlots(self);

    if (args.length >= 1) {
      self.__setattr__("msg", args[0]);
    }
    if (args.length == 2) {
      PyObject[] info = Py.make_array(args[1]);
      if (info.length != 4) {
        throw Py.IndexError("tuple index out of range");
      }

      self.__setattr__("filename", info[0]);
      self.__setattr__("lineno", info[1]);
      self.__setattr__("offset", info[2]);
      self.__setattr__("text", info[3]);
    }
  }
示例#7
0
 @ExposedMethod(doc = BuiltinDocs.function___setattr___doc)
 final void function___setattr__(String name, PyObject value) {
   ensureDict();
   super.__setattr__(name, value);
 }