mirror of
https://github.com/python/cpython
synced 2026-09-29 09:00:29 +03:00
Make a few more tests pass with the new I/O library.
Fix the truncate() semantics -- it should not affect the current position. Switch wave.py/chunk.py to struct.unpack_from() to support bytes. Don't use writelines() on binary files (test_fileinput.py).
This commit is contained in:
parent
b6f1fdc90c
commit
dc0b1a1069
6 changed files with 16 additions and 20 deletions
|
|
@ -519,7 +519,7 @@ fileio_truncate(PyFileIOObject *self, PyObject *args)
|
|||
{
|
||||
PyObject *posobj = NULL;
|
||||
Py_off_t pos;
|
||||
int fd, whence;
|
||||
int fd;
|
||||
|
||||
fd = self->fd;
|
||||
if (fd < 0)
|
||||
|
|
@ -530,17 +530,14 @@ fileio_truncate(PyFileIOObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "|O", &posobj))
|
||||
return NULL;
|
||||
|
||||
if (posobj == Py_None)
|
||||
posobj = NULL;
|
||||
|
||||
if (posobj == NULL)
|
||||
whence = 1;
|
||||
else
|
||||
whence = 0;
|
||||
|
||||
posobj = portable_lseek(fd, posobj, whence);
|
||||
if (posobj == NULL)
|
||||
return NULL;
|
||||
if (posobj == Py_None || posobj == NULL) {
|
||||
posobj = portable_lseek(fd, NULL, 1);
|
||||
if (posobj == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
Py_INCREF(posobj);
|
||||
}
|
||||
|
||||
#if !defined(HAVE_LARGEFILE_SUPPORT)
|
||||
pos = PyInt_AsLong(posobj);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue