This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pakal
Recipients georg.brandl, pakal
Date 2009-12-19.15:59:09
SpamBayes Score 2.8660407e-13
Marked as misclassified No
Message-id <1261238351.34.0.64888213085.issue7545@psf.upfronthosting.co.za>
In-reply-to
Content
Hello,
It seems there is an important difference between the doc of the IO
module, and its implementation so far (until todcay trunk revision 76805)

"buffering is an optional integer used to set the buffering policy. By
default full buffering is on. Pass 0 to switch buffering off (only
allowed in binary mode), 1 to set line buffering, and an integer > 1 for
full buffering."
--> actually full buffering only occurs if a negative buffering
parameter is given, else it seems th current value i kept as the buffer
size - eg. if we give "3", buffering will be 3 bytes...
This seems a fine behaviour to me, so this implementation could just be
documented as is.

-----------
Only case of full buffering in the C iomodule :
    if (buffering < 0) {
        buffering = DEFAULT_BUFFER_SIZE;
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
        {
            struct stat st;
            long fileno;
            PyObject *res = PyObject_CallMethod(raw, "fileno", NULL);
            if (res == NULL)
                goto error;

            fileno = PyInt_AsLong(res);
            Py_DECREF(res);
            if (fileno == -1 && PyErr_Occurred())
                goto error;

            if (fstat(fileno, &st) >= 0)
                buffering = st.st_blksize;
        }
#endif
    }
History
Date User Action Args
2009-12-19 15:59:11pakalsetrecipients: + pakal, georg.brandl
2009-12-19 15:59:11pakalsetmessageid: <1261238351.34.0.64888213085.issue7545@psf.upfronthosting.co.za>
2009-12-19 15:59:10pakallinkissue7545 messages
2009-12-19 15:59:09pakalcreate