Teks sumber — English
Terjemahan — Bahasa Indonesia
This format does not accept :term:`bytes-like objects <bytes-like object>`. If you want to accept filesystem paths and convert them to C character strings, it is preferable to use the ``O&`` format with :c:func:`PyUnicode_FSConverter` as *converter*.
``O&`` (object) [*converter*, *address*]
``O&`` (objek) [*converter*, *adress*]
Convert a Python object to a C variable through a *converter* function. This takes two arguments: the first is a function, the second is the address of a C variable (of arbitrary type), converted to :c:expr:`void *`. The *converter* function in turn is called as follows::
Mengonversi objek Python ke variabel C melalui fungsi *converter*. Ini membutuhkan dua argumen: yang pertama adalah fungsi, yang kedua adalah alamat variabel C (dari tipe sembarang), yang dikonversi menjadi :c:expr:`void *`. Fungsi *converter* pada gilirannya dipanggil sebagai berikut::
status = converter(object, address);
status = converter(objek, adress);
where *object* is the Python object to be converted and *address* is the :c:expr:`void*` argument that was passed to the ``PyArg_Parse*`` function. The returned *status* should be ``1`` for a successful conversion and ``0`` if the conversion has failed. When the conversion fails, the *converter* function should raise an exception and leave the content of *address* unmodified.
di mana *object* adalah objek Python yang akan dikonversi dan *address* adalah argumen :c:expr:`void*` yang diteruskan ke fungsi ``PyArg_Parse*``. *status* yang dikembalikan harus ``1`` untuk konversi yang berhasil dan ``0`` jika konversi gagal. Ketika konversi gagal, fungsi *converter* akan memunculkan pengecualian dan membiarkan konten *address* tidak diubah.
If the *converter* returns :c:macro:`!Py_CLEANUP_SUPPORTED`, it may get called a second time if the argument parsing eventually fails, giving the converter a chance to release any memory that it had already allocated. In this second call, the *object* parameter will be ``NULL``; *address* will have the same value as in the original call.
Jika *converter* mengembalikan :c:macro:`!Py_CLEANUP_SUPPORTED`, ia mungkin akan dipanggil untuk kedua kalinya jika penguraian argumen pada akhirnya gagal, memberikan kesempatan kepada konverter untuk melepaskan memori yang telah dialokasikan. Pada pemanggilan kedua ini, parameter *object* akan menjadi ``NULL``; *address* akan memiliki nilai yang sama dengan pemanggilan pertama.
Examples of converters: :c:func:`PyUnicode_FSConverter` and :c:func:`PyUnicode_FSDecoder`.
Contoh konverter: :c:func:`PyUnicode_FSConverter` dan :c:func:`PyUnicode_FSDecoder`.
If *items* contains format units which store a :ref:`borrowed buffer <c-arg-borrowed-buffer>` (``s``, ``s#``, ``z``, ``z#``, ``y``, or ``y#``) or a :term:`borrowed reference` (``S``, ``Y``, ``U``, ``O``, or ``O!``), the object must be a Python tuple. The *converter* for the ``O&`` format unit in *items* must not store a borrowed buffer or a borrowed reference.
Jika *items* berisi unit format yang menyimpan :ref:`borrowed buffer <c-arg-borrowed-buffer>` (``s``, ``s#``, ``z``, ``z#``, ``y``, atau ``y#``) atau :term:`borrowed reference` (``S``, ``Y``, ``U``, ``O``, atau ``O!``), maka objek tersebut haruslah sebuah tuple Python. *converter* untuk unit format ``O&`` dalam *items* tidak boleh menyimpan buffer yang dipinjam atau referensi yang dipinjam.
``O&`` (object) [*converter*, *anything*]
``O&`` (object) [*converter*, *anything*]
Convert *anything* to a Python object through a *converter* function. The function is called with *anything* (which should be compatible with :c:expr:`void*`) as its argument and should return a "new" Python object, or ``NULL`` if an error occurred.
Mengonversi *anything* menjadi objek Python melalui fungsi *converter*. Fungsi ini dipanggil dengan *anything* (yang seharusnya kompatibel dengan :c:expr:`void*`) sebagai argumennya dan akan mengembalikan objek Python "new", atau ``NULL`` jika terjadi kesalahan.