}
public static PyObject fdopen(PyObject fd, String mode, int bufsize) {
if (mode.length() == 0 || !"rwa".contains("" + mode.charAt(0))) {
throw Py.ValueError(String.format("invalid file mode '%s'", mode));
}
RawIOBase rawIO = FileDescriptors.get(fd);
if (rawIO.closed()) {
throw badFD();
}
try {
return new PyFile(rawIO, "<fdopen>", mode, bufsize);