diff options
author | Guido van Rossum <guido@python.org> | 2000-03-10 22:55:18 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-03-10 22:55:18 (GMT) |
commit | 4c08d554b9009899780a5e003d6bbeb5413906ee (patch) | |
tree | 342df952b99b7d4e2ce8e51e8dd65d23744318b6 /Objects/fileobject.c | |
parent | d57fd91488212f5b891da5caf6bc04a907659cbd (diff) | |
download | cpython-4c08d554b9009899780a5e003d6bbeb5413906ee.zip cpython-4c08d554b9009899780a5e003d6bbeb5413906ee.tar.gz cpython-4c08d554b9009899780a5e003d6bbeb5413906ee.tar.bz2 |
Many changes for Unicode, by Marc-Andre Lemburg.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r-- | Objects/fileobject.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 5b3d6eb..60c113f 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -75,6 +75,8 @@ typedef struct { PyObject *f_mode; int (*f_close) Py_PROTO((FILE *)); int f_softspace; /* Flag used by 'print' command */ + int f_binary; /* Flag which indicates whether the file is open + open in binary (1) or test (0) mode */ } PyFileObject; FILE * @@ -112,6 +114,10 @@ PyFile_FromFile(fp, name, mode, close) f->f_mode = PyString_FromString(mode); f->f_close = close; f->f_softspace = 0; + if (strchr(mode,'b') != NULL) + f->f_binary = 1; + else + f->f_binary = 0; if (f->f_name == NULL || f->f_mode == NULL) { Py_DECREF(f); return NULL; @@ -863,7 +869,7 @@ file_write(f, args) int n, n2; if (f->f_fp == NULL) return err_closed(); - if (!PyArg_Parse(args, "s#", &s, &n)) + if (!PyArg_Parse(args, f->f_binary ? "s#" : "t#", &s, &n)) return NULL; f->f_softspace = 0; Py_BEGIN_ALLOW_THREADS |