Objek File
**********

These APIs are a minimal emulation of the Python 2 C API for built-in
file objects, which used to rely on the buffered I/O (FILE*) support
from the C standard library.  In Python 3, files and streams use the
new "io" module, which defines several layers over the low-level
unbuffered I/O of the operating system.  The functions described below
are convenience C wrappers over these new APIs, and meant mostly for
internal error reporting in the interpreter; third-party code is
advised to access the "io" APIs instead.

PyObject *PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd)
    *Return value: New reference.** Part of the Stable ABI.*

   Membuat objek file Python dari deskriptor file dari file yang sudah
   dibuka *fd*. Argumen *name*, *encoding*, *errors* dan * newline*
   bisa "NULL" untuk menggunakan nilai default; *buffering* bisa *-1*
   untuk menggunakan default. *name* diabaikan dan disimpan untuk
   kompatibilitas ke belakang. Mengembalikan "NULL" jika gagal. Untuk
   penjelasan yang lebih lengkap tentang argumen, silakan merujuk ke
   dokumentasi fungsi  "io.open()".

   Peringatan:

     Karena aliran Python memiliki lapisan penyangga sendiri,
     mencampurnya dengan deskriptor file tingkat OS dapat menghasilkan
     berbagai masalah (seperti pengurutan data yang tidak terduga).

   Berubah pada versi 3.2: Abaikan atribut *name*.

int PyObject_AsFileDescriptor(PyObject *p)
    * Part of the Stable ABI.*

   Return the file descriptor associated with *p* as an int.  If the
   object is an integer, its value is returned.  If not, the object's
   "fileno()" method is called if it exists; the method must return an
   integer, which is returned as the file descriptor value.  Sets an
   exception and returns "-1" on failure.

PyObject *PyFile_GetLine(PyObject *p, int n)
    *Return value: New reference.** Part of the Stable ABI.*

   Setara dengan "p.readline([n])", fungsi ini membaca satu baris dari
   objek *p*. *p* dapat berupa objek file atau objek apa pun dengan
   metode "readline()". Jika *n* adalah "0", tepat satu baris terbaca,
   berapa pun panjang barisnya. Jika *n* lebih besar dari "0", tidak
   lebih dari *n* byte yang akan dibaca dari file; garis parsial dapat
   dikembalikan. Dalam kedua kasus, string kosong dikembalikan jika
   akhir file dicapai dengan segera. Jika *n* lebih kecil dari "0",
   bagaimanapun, satu baris dibaca berapa pun panjangnya, tapi
   "EOFError" dimunculkan jika akhir file dicapai dengan segera.

int PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction handler)

   Mengganti perilaku normal "io.open_code()" untuk meneruskan
   parameternya melalui penangan yang disediakan.

   The *handler* is a function of type:

   typedef PyObject *(*Py_OpenCodeHookFunction)(PyObject*, void*)

      Equivalent of PyObject *(*)(PyObject *path, void *userData),
      where *path* is guaranteed to be "PyUnicodeObject".

   Pointer *userData* diteruskan ke fungsi hook. Karena fungsi hook
   dapat dipanggil dari runtime yang berbeda, pointer ini tidak boleh
   merujuk langsung ke status Python.

   Karena hook ini sengaja digunakan selama impor, hindari mengimpor
   modul baru selama eksekusinya kecuali jika mereka diketahui telah
   dibekukan atau tersedia di "sys.modules".

   Setelah hook diatur, hook tidak dapat dilepas atau diganti, dan
   panggilan ke "PyFile_SetOpenCodeHook()" akan gagal. Jika gagal,
   fungsi mengembalikan -1 dan mengatur pengecualian jika interpreter
   telah diinisialisasi.

   Fungsi ini aman untuk dipanggil sebelum "Py_Initialize()".

   Raises an auditing event "setopencodehook" with no arguments.

   Added in version 3.8.

int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)
    * Part of the Stable ABI.*

   Write object *obj* to file object *p*.  The only supported flag for
   *flags* is "Py_PRINT_RAW"; if given, the "str()" of the object is
   written instead of the "repr()".  Return "0" on success or "-1" on
   failure; the appropriate exception will be set.

int PyFile_WriteString(const char *s, PyObject *p)
    * Part of the Stable ABI.*

   Menulis string *s* ke file objek *p*. Mengembalikan "0" saat sukses
   atau "-1" saat gagal; pengecualian yang sesuai akan ditetapkan.
