[Python-Dev] OpenVMS file system and UNIVERSAL_NEWLINES support
Jean-François Piéronne
jf.pieronne at laposte.net
Wed Feb 25 11:39:08 EST 2004
Jack Jansen wrote:
>
> On 23-feb-04, at 18:15, Jean-François Piéronne wrote:
>
>> Hi all,
>>
>> I am one of the maintainer of Python on OpenVMS.
>>
>> Building from time to time Python 2.4 from CVS snapshot, I have just
>> noticed that all the conditional compilation against
>> WITH_UNIVERSAL_NEWLINES has been removed.
>>
>> This is a major problem on OpenVMS.
>
>
> Ah, I was afraid this was going to happen when I saw the checkin message
> about getting rid of the universal newlines conditional.
>
> The easiest solution (apart from putting WITH_UNIVERSAL_NEWLINES back
> in) is to just leave all the universal newlines machinery in place, but
> disable it. So, where the old situation was that there were ifdefs all
> over the place the new situation would be that all the code always goes
> through Py_UniversalNewlineFgets() and Py_UniversalNewlineFread(), but
> on systems with record-based I/O these just call fgets() and fread().
> Then there's only one more ifdef to go: in open_the_file() don't set the
> mode to "rb" but just plain "r".
>
> I assume that sockets and other places where WITH_UNIVERSAL_NEWLINES may
> have been referred to aren't going to be a problem for you because
> those aren't applicable to VMS anyway, right?
> --
> Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
> If I can't dance I don't want to be part of your revolution -- Emma Goldman
>
thanks for your help,
Before I submit a patch, I have done the following update which seem to fix
the problem, any comment are welcome.
patch for include/fileobject.h
@@ -54,3 +54,7 @@
*/
+#ifdef __VMS
+#define PY_STDIOTEXTMODE ""
+#else
#define PY_STDIOTEXTMODE "b"
+#endif
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
patch for objects/fileobject.c
@@ -119,3 +124,7 @@
f->f_buf = NULL;
+#ifdef __VMS
+ f->f_univ_newline = 0;
+#else
f->f_univ_newline = (strchr(mode, 'U') != NULL);
+#endif
f->f_newlinetypes = NEWLINE_UNKNOWN;
@@ -164,3 +173,11 @@
if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0)
+#ifdef __VMS
+ /* Compatibility: specifying U in a Python without universal
+ ** newlines is allowed, and the file is opened as a normal text
+ ** file.
+ */
+ mode = "r";
+#else
mode = "rb";
+#endif
#ifdef MS_WINDOWS
patch for modules/bz2modules.c
@@ -1293,3 +1293,7 @@
case 'U':
+#ifdef __VMS
+ self->f_univ_newline = 0;
+#else
self->f_univ_newline = 1;
+#endif
break;
Cheers,
Jean-François
More information about the Python-Dev
mailing list