[issue9838] Inadequate C-API to Python 3 I/O objects

Pauli Virtanen report at bugs.python.org
Sun Sep 12 15:23:47 CEST 2010


New submission from Pauli Virtanen <pav at iki.fi>:

The C-API exposed by the `io` module on Python 3.1/3.2 is very limited, and makes interfacing with Python file objects in extension modules difficult.

In more detail:

1) Because the Python layer has buffering etc., the file handle returned by `PyObject_AsFileDescriptor` is not usable as-is. It requires flush and seek before use, every time there is a chance that the file object has been accessed on the Python side. 

2) There are no C-API functions such as the minimal set of `PyFile_Write(buf, length)`, `PyFile_Read(buf, length)`, `PyFile_Seek(pos, whence)`, `PyFile_Tell()`.

Instead, every call must go through PyObject_CallMethod, and the file objects only handle `PyBytes` and `PyByteArray` which are cumbersome and inefficient to use in extension modules.

----------
components: Extension Modules
messages: 116188
nosy: pv
priority: normal
severity: normal
status: open
title: Inadequate C-API to Python 3 I/O objects
type: feature request
versions: Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9838>
_______________________________________


More information about the Python-bugs-list mailing list