~pythonregexp2.7/python/issue2636-01+09-02

« back to all changes in this revision

Viewing changes to Modules/_fileio.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:16:16 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922001616-p1wdip9lfp0zl5cu
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
                                                 kwlist,
176
176
                                                 Py_FileSystemDefaultEncoding,
177
177
                                                 &name, &mode, &closefd))
178
 
                        goto error;
 
178
                        return -1;
179
179
            }
180
180
        }
181
181
 
262
262
#endif
263
263
                        self->fd = open(name, flags, 0666);
264
264
                Py_END_ALLOW_THREADS
265
 
                if (self->fd < 0 || dircheck(self) < 0) {
 
265
                if (self->fd < 0) {
266
266
#ifdef MS_WINDOWS
267
267
                        PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
268
268
#else
270
270
#endif
271
271
                        goto error;
272
272
                }
 
273
                if(dircheck(self) < 0)
 
274
                        goto error;
273
275
        }
274
276
 
275
277
        goto done;
358
360
static PyObject *
359
361
fileio_readinto(PyFileIOObject *self, PyObject *args)
360
362
{
361
 
        char *ptr;
 
363
        Py_buffer pbuf;
362
364
        Py_ssize_t n;
363
365
 
364
366
        if (self->fd < 0)
366
368
        if (!self->readable)
367
369
                return err_mode("reading");
368
370
 
369
 
        if (!PyArg_ParseTuple(args, "w#", &ptr, &n))
 
371
        if (!PyArg_ParseTuple(args, "w*", &pbuf))
370
372
                return NULL;
371
373
 
372
374
        Py_BEGIN_ALLOW_THREADS
373
375
        errno = 0;
374
 
        n = read(self->fd, ptr, n);
 
376
        n = read(self->fd, pbuf.buf, pbuf.len);
375
377
        Py_END_ALLOW_THREADS
 
378
        PyBuffer_Release(&pbuf);
376
379
        if (n < 0) {
377
380
                if (errno == EAGAIN)
378
381
                        Py_RETURN_NONE;
490
493
static PyObject *
491
494
fileio_write(PyFileIOObject *self, PyObject *args)
492
495
{
 
496
        Py_buffer pbuf;
493
497
        Py_ssize_t n;
494
 
        char *ptr;
495
498
 
496
499
        if (self->fd < 0)
497
500
                return err_closed();
498
501
        if (!self->writable)
499
502
                return err_mode("writing");
500
503
 
501
 
        if (!PyArg_ParseTuple(args, "s#", &ptr, &n))
 
504
        if (!PyArg_ParseTuple(args, "s*", &pbuf))
502
505
                return NULL;
503
506
 
504
507
        Py_BEGIN_ALLOW_THREADS
505
508
        errno = 0;
506
 
        n = write(self->fd, ptr, n);
 
509
        n = write(self->fd, pbuf.buf, pbuf.len);
507
510
        Py_END_ALLOW_THREADS
508
511
 
 
512
        PyBuffer_Release(&pbuf);
 
513
 
509
514
        if (n < 0) {
510
515
                if (errno == EAGAIN)
511
516
                        Py_RETURN_NONE;