X Tutup
Skip to content

Commit db60805

Browse files
author
Skip Montanaro
committed
Remove support for --without-universal-newlines (see PEP 11).
1 parent f1afe66 commit db60805

File tree

11 files changed

+7
-128
lines changed

11 files changed

+7
-128
lines changed

Include/fileobject.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ typedef struct {
2020
char* f_bufend; /* Points after last occupied position */
2121
char* f_bufptr; /* Current buffer position */
2222
char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */
23-
#ifdef WITH_UNIVERSAL_NEWLINES
2423
int f_univ_newline; /* Handle any newline convention */
2524
int f_newlinetypes; /* Types of newlines seen */
2625
int f_skipnextlf; /* Skip next \n */
27-
#endif
2826
PyObject *f_encoding;
2927
} PyFileObject;
3028

@@ -51,19 +49,13 @@ PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
5149
*/
5250
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
5351

54-
#ifdef WITH_UNIVERSAL_NEWLINES
5552
/* Routines to replace fread() and fgets() which accept any of \r, \n
5653
or \r\n as line terminators.
5754
*/
5855
#define PY_STDIOTEXTMODE "b"
5956
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
6057
size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *);
61-
#else
62-
#define PY_STDIOTEXTMODE ""
63-
#define Py_UniversalNewlineFgets(buf, len, fp, obj) fgets((buf), (len), (fp))
64-
#define Py_UniversalNewlineFread(buf, len, fp, obj) \
65-
fread((buf), 1, (len), (fp))
66-
#endif /* WITH_UNIVERSAL_NEWLINES */
58+
6759
#ifdef __cplusplus
6860
}
6961
#endif

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ Tools/Demos
330330
Build
331331
-----
332332

333+
- Systems requiring the D4, D6 or D7 variants of pthreads are no longer
334+
supported (see PEP 11).
335+
336+
- Universal newline support can no longer be disabled (see PEP 11).
337+
333338
- Support for DGUX, SunOS 4, IRIX 4 and Minix was removed (see PEP 11).
334339

335340
- Support for systems requiring --with-dl-dld or --with-sgi-dl was removed

Modules/bz2module.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ static char __author__[] =
7373
#define RELEASE_LOCK(obj)
7474
#endif
7575

76-
#ifdef WITH_UNIVERSAL_NEWLINES
7776
/* Bits in f_newlinetypes */
7877
#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */
7978
#define NEWLINE_CR 1 /* \r newline seen */
8079
#define NEWLINE_LF 2 /* \n newline seen */
8180
#define NEWLINE_CRLF 4 /* \r\n newline seen */
82-
#endif
8381

8482
/* ===================================================================== */
8583
/* Structure definitions. */
@@ -94,11 +92,9 @@ typedef struct {
9492

9593
int f_softspace; /* Flag used by 'print' command */
9694

97-
#ifdef WITH_UNIVERSAL_NEWLINES
9895
int f_univ_newline; /* Handle any newline convention */
9996
int f_newlinetypes; /* Types of newlines seen */
10097
int f_skipnextlf; /* Skip next \n */
101-
#endif
10298

10399
BZFILE *fp;
104100
int mode;
@@ -227,11 +223,9 @@ Util_GetLine(BZ2FileObject *f, int n)
227223
size_t increment; /* amount to increment the buffer */
228224
PyObject *v;
229225
int bzerror;
230-
#ifdef WITH_UNIVERSAL_NEWLINES
231226
int newlinetypes = f->f_newlinetypes;
232227
int skipnextlf = f->f_skipnextlf;
233228
int univ_newline = f->f_univ_newline;
234-
#endif
235229

236230
total_v_size = n > 0 ? n : 100;
237231
v = PyString_FromStringAndSize((char *)NULL, total_v_size);
@@ -243,7 +237,6 @@ Util_GetLine(BZ2FileObject *f, int n)
243237

244238
for (;;) {
245239
Py_BEGIN_ALLOW_THREADS
246-
#ifdef WITH_UNIVERSAL_NEWLINES
247240
if (univ_newline) {
248241
while (1) {
249242
BZ2_bzRead(&bzerror, f->fp, &c, 1);
@@ -277,17 +270,14 @@ Util_GetLine(BZ2FileObject *f, int n)
277270
if (bzerror == BZ_STREAM_END && skipnextlf)
278271
newlinetypes |= NEWLINE_CR;
279272
} else /* If not universal newlines use the normal loop */
280-
#endif
281273
do {
282274
BZ2_bzRead(&bzerror, f->fp, &c, 1);
283275
f->pos++;
284276
*buf++ = c;
285277
} while (bzerror == BZ_OK && c != '\n' && buf != end);
286278
Py_END_ALLOW_THREADS
287-
#ifdef WITH_UNIVERSAL_NEWLINES
288279
f->f_newlinetypes = newlinetypes;
289280
f->f_skipnextlf = skipnextlf;
290-
#endif
291281
if (bzerror == BZ_STREAM_END) {
292282
f->size = f->pos;
293283
f->mode = MODE_READ_EOF;
@@ -323,9 +313,6 @@ Util_GetLine(BZ2FileObject *f, int n)
323313
return v;
324314
}
325315

326-
#ifndef WITH_UNIVERSAL_NEWLINES
327-
#define Util_UnivNewlineRead(a,b,c,d,e) BZ2_bzRead(a,b,c,d)
328-
#else
329316
/* This is a hacked version of Python's
330317
* fileobject.c:Py_UniversalNewlineFread(). */
331318
size_t
@@ -393,7 +380,6 @@ Util_UnivNewlineRead(int *bzerror, BZFILE *stream,
393380
f->f_skipnextlf = skipnextlf;
394381
return dst - buf;
395382
}
396-
#endif
397383

398384
/* This is a hacked version of Python's fileobject.c:drop_readahead(). */
399385
static void
@@ -1190,7 +1176,6 @@ static PyMethodDef BZ2File_methods[] = {
11901176
/* ===================================================================== */
11911177
/* Getters and setters of BZ2File. */
11921178

1193-
#ifdef WITH_UNIVERSAL_NEWLINES
11941179
/* This is a hacked version of Python's fileobject.c:get_newlines(). */
11951180
static PyObject *
11961181
BZ2File_get_newlines(BZ2FileObject *self, void *closure)
@@ -1220,7 +1205,6 @@ BZ2File_get_newlines(BZ2FileObject *self, void *closure)
12201205
return NULL;
12211206
}
12221207
}
1223-
#endif
12241208

12251209
static PyObject *
12261210
BZ2File_get_closed(BZ2FileObject *self, void *closure)
@@ -1243,10 +1227,8 @@ BZ2File_get_name(BZ2FileObject *self, void *closure)
12431227
static PyGetSetDef BZ2File_getset[] = {
12441228
{"closed", (getter)BZ2File_get_closed, NULL,
12451229
"True if the file is closed"},
1246-
#ifdef WITH_UNIVERSAL_NEWLINES
12471230
{"newlines", (getter)BZ2File_get_newlines, NULL,
12481231
"end-of-line convention used in this file"},
1249-
#endif
12501232
{"mode", (getter)BZ2File_get_mode, NULL,
12511233
"file mode ('r', 'w', or 'U')"},
12521234
{"name", (getter)BZ2File_get_name, NULL,
@@ -1309,9 +1291,7 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
13091291
break;
13101292

13111293
case 'U':
1312-
#ifdef WITH_UNIVERSAL_NEWLINES
13131294
self->f_univ_newline = 1;
1314-
#endif
13151295
break;
13161296

13171297
default:
@@ -1441,7 +1421,6 @@ exist, and truncated otherwise. If the buffering argument is given, 0 means\n\
14411421
unbuffered, and larger numbers specify the buffer size. If compresslevel\n\
14421422
is given, must be a number between 1 and 9.\n\
14431423
")
1444-
#ifdef WITH_UNIVERSAL_NEWLINES
14451424
PyDoc_STR(
14461425
"\n\
14471426
Add a 'U' to mode to open the file for input with universal newline\n\
@@ -1451,7 +1430,6 @@ for this attribute is one of None (no newline read yet), '\\r', '\\n',\n\
14511430
'\\r\\n' or a tuple containing all the newline types seen. Universal\n\
14521431
newlines are available only when reading.\n\
14531432
")
1454-
#endif
14551433
;
14561434

14571435
static PyTypeObject BZ2File_Type = {

Objects/fileobject.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@
4141
#define FUNLOCKFILE(f)
4242
#endif
4343

44-
#ifdef WITH_UNIVERSAL_NEWLINES
4544
/* Bits in f_newlinetypes */
4645
#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */
4746
#define NEWLINE_CR 1 /* \r newline seen */
4847
#define NEWLINE_LF 2 /* \n newline seen */
4948
#define NEWLINE_CRLF 4 /* \r\n newline seen */
50-
#endif
5149

5250
FILE *
5351
PyFile_AsFile(PyObject *f)
@@ -119,11 +117,9 @@ fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode,
119117
f->f_softspace = 0;
120118
f->f_binary = strchr(mode,'b') != NULL;
121119
f->f_buf = NULL;
122-
#ifdef WITH_UNIVERSAL_NEWLINES
123120
f->f_univ_newline = (strchr(mode, 'U') != NULL);
124121
f->f_newlinetypes = NEWLINE_UNKNOWN;
125122
f->f_skipnextlf = 0;
126-
#endif
127123
Py_INCREF(Py_None);
128124
f->f_encoding = Py_None;
129125

@@ -165,17 +161,8 @@ open_the_file(PyFileObject *f, char *name, char *mode)
165161
else
166162
#endif
167163
{
168-
#ifdef WITH_UNIVERSAL_NEWLINES
169164
if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0)
170165
mode = "rb";
171-
#else
172-
/* Compatibility: specifying U in a Python without universal
173-
** newlines is allowed, and the file is opened as a normal text
174-
** file.
175-
*/
176-
if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0)
177-
mode = "r";
178-
#endif
179166
#ifdef MS_WINDOWS
180167
if (PyUnicode_Check(f->f_name)) {
181168
PyObject *wmode;
@@ -494,9 +481,7 @@ file_seek(PyFileObject *f, PyObject *args)
494481
clearerr(f->f_fp);
495482
return NULL;
496483
}
497-
#ifdef WITH_UNIVERSAL_NEWLINES
498484
f->f_skipnextlf = 0;
499-
#endif
500485
Py_INCREF(Py_None);
501486
return Py_None;
502487
}
@@ -629,7 +614,6 @@ file_tell(PyFileObject *f)
629614
clearerr(f->f_fp);
630615
return NULL;
631616
}
632-
#ifdef WITH_UNIVERSAL_NEWLINES
633617
if (f->f_skipnextlf) {
634618
int c;
635619
c = GETC(f->f_fp);
@@ -638,7 +622,6 @@ file_tell(PyFileObject *f)
638622
f->f_skipnextlf = 0;
639623
} else if (c != EOF) ungetc(c, f->f_fp);
640624
}
641-
#endif
642625
#if !defined(HAVE_LARGEFILE_SUPPORT)
643626
return PyInt_FromLong(pos);
644627
#else
@@ -1070,18 +1053,12 @@ get_line(PyFileObject *f, int n)
10701053
size_t used_v_size; /* # used slots in buffer */
10711054
size_t increment; /* amount to increment the buffer */
10721055
PyObject *v;
1073-
#ifdef WITH_UNIVERSAL_NEWLINES
10741056
int newlinetypes = f->f_newlinetypes;
10751057
int skipnextlf = f->f_skipnextlf;
10761058
int univ_newline = f->f_univ_newline;
1077-
#endif
10781059

10791060
#if defined(USE_FGETS_IN_GETLINE)
1080-
#ifdef WITH_UNIVERSAL_NEWLINES
10811061
if (n <= 0 && !univ_newline )
1082-
#else
1083-
if (n <= 0)
1084-
#endif
10851062
return getline_via_fgets(fp);
10861063
#endif
10871064
total_v_size = n > 0 ? n : 100;
@@ -1094,7 +1071,6 @@ get_line(PyFileObject *f, int n)
10941071
for (;;) {
10951072
Py_BEGIN_ALLOW_THREADS
10961073
FLOCKFILE(fp);
1097-
#ifdef WITH_UNIVERSAL_NEWLINES
10981074
if (univ_newline) {
10991075
c = 'x'; /* Shut up gcc warning */
11001076
while ( buf != end && (c = GETC(fp)) != EOF ) {
@@ -1123,17 +1099,14 @@ get_line(PyFileObject *f, int n)
11231099
if ( c == EOF && skipnextlf )
11241100
newlinetypes |= NEWLINE_CR;
11251101
} else /* If not universal newlines use the normal loop */
1126-
#endif
11271102
while ((c = GETC(fp)) != EOF &&
11281103
(*buf++ = c) != '\n' &&
11291104
buf != end)
11301105
;
11311106
FUNLOCKFILE(fp);
11321107
Py_END_ALLOW_THREADS
1133-
#ifdef WITH_UNIVERSAL_NEWLINES
11341108
f->f_newlinetypes = newlinetypes;
11351109
f->f_skipnextlf = skipnextlf;
1136-
#endif
11371110
if (c == '\n')
11381111
break;
11391112
if (c == EOF) {
@@ -1677,7 +1650,6 @@ get_closed(PyFileObject *f, void *closure)
16771650
{
16781651
return PyBool_FromLong((long)(f->f_fp == 0));
16791652
}
1680-
#ifdef WITH_UNIVERSAL_NEWLINES
16811653
static PyObject *
16821654
get_newlines(PyFileObject *f, void *closure)
16831655
{
@@ -1706,14 +1678,11 @@ get_newlines(PyFileObject *f, void *closure)
17061678
return NULL;
17071679
}
17081680
}
1709-
#endif
17101681

17111682
static PyGetSetDef file_getsetlist[] = {
17121683
{"closed", (getter)get_closed, NULL, "True if the file is closed"},
1713-
#ifdef WITH_UNIVERSAL_NEWLINES
17141684
{"newlines", (getter)get_newlines, NULL,
17151685
"end-of-line convention used in this file"},
1716-
#endif
17171686
{0},
17181687
};
17191688

@@ -1931,7 +1900,6 @@ PyDoc_STR(
19311900
"If the buffering argument is given, 0 means unbuffered, 1 means line\n"
19321901
"buffered, and larger numbers specify the buffer size.\n"
19331902
)
1934-
#ifdef WITH_UNIVERSAL_NEWLINES
19351903
PyDoc_STR(
19361904
"Add a 'U' to mode to open the file for input with universal newline\n"
19371905
"support. Any line ending in the input file will be seen as a '\\n'\n"
@@ -1941,7 +1909,6 @@ PyDoc_STR(
19411909
"\n"
19421910
"'U' cannot be combined with 'w' or '+' mode.\n"
19431911
)
1944-
#endif /* WITH_UNIVERSAL_NEWLINES */
19451912
PyDoc_STR(
19461913
"\n"
19471914
"Note: open() is an alias for file()."
@@ -2181,7 +2148,6 @@ int PyObject_AsFileDescriptor(PyObject *o)
21812148
return fd;
21822149
}
21832150

2184-
#ifdef WITH_UNIVERSAL_NEWLINES
21852151
/* From here on we need access to the real fgets and fread */
21862152
#undef fgets
21872153
#undef fread
@@ -2359,4 +2325,3 @@ Py_UniversalNewlineFread(char *buf, size_t n,
23592325
f->f_skipnextlf = skipnextlf;
23602326
return dst - buf;
23612327
}
2362-
#endif

PC/os2emx/pyconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
/* enable the GC module */
5454
#define WITH_CYCLE_GC 1
5555

56-
/* Define if you want to read files with foreign newlines. */
57-
#define WITH_UNIVERSAL_NEWLINES 1
58-
5956
/* Define if you want documentation strings in extension modules */
6057
#define WITH_DOC_STRINGS 1
6158

PC/pyconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
397397
/* Use Python's own small-block memory-allocator. */
398398
#define WITH_PYMALLOC 1
399399

400-
/* Enable \n, \r, \r\n line ends on import; also the 'U' mode flag for open. */
401-
#define WITH_UNIVERSAL_NEWLINES 1
402-
403400
/* Define if you have clock. */
404401
/* #define HAVE_CLOCK */
405402

Parser/pgenmain.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,12 @@ PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
145145
return PyMem_REALLOC(p, n+1);
146146
}
147147

148-
#ifdef WITH_UNIVERSAL_NEWLINES
149148
/* No-nonsense fgets */
150149
char *
151150
Py_UniversalNewlineFgets(char *buf, int n, FILE *stream, PyObject *fobj)
152151
{
153152
return fgets(buf, n, stream);
154153
}
155-
#endif
156154

157155

158156
#include <stdarg.h>

RISCOS/pyconfig.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@
226226
one supplied by Python itself. (see Include/unicodectype.h). */
227227
#undef WANT_WCTYPE_FUNCTIONS
228228

229-
/* Define if you want to read files with foreign newlines. */
230-
#define WITH_UNIVERSAL_NEWLINES 1
231-
232229
/* Define if you want documentation strings in extension modules */
233230
#define WITH_DOC_STRINGS 1
234231

0 commit comments

Comments
 (0)
X Tutup