Re: [Python-Dev] Patch submitted for cross-platform newline support
Recently, "Tim Peters"
Well, the "t" modifier isn't std; does anyone other than Microsoft support it? MS also gives meaning to non-std "c" and "n" modifiers. Luckily, Python doesn't define which modes or modifiers it accepts <wink>.
Oops, big oops! I picked the "t" because it was intended _not_ to be supported on any platform: my code eats it, and turns on the universal newline feature on the file object. What does "t" do on Windows? What would be a better choice? -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm
[Jack Jansen]
Oops, big oops! I picked the "t" because it was intended _not_ to be supported on any platform: my code eats it, and turns on the universal newline feature on the file object. What does "t" do on Windows?
MS treats "t" as an explicit way of saying "not b" <wink>, i.e. text mode. The MS libraries can be configured to use "b" as the default, and then you need "t" to force text mode (when needed).
What would be a better choice?
I don't know. MS adds t, c and n as extensions to C's fopen() gimmicks, and there's really no way to guess what the union of all other platforms may do. Python (before your patch) passes on *whatever* mode string the user supplies, without even peeking at it. That's a mixed blessing: I've been very happy to be able to pass "c" on MS (which triggers a "commit" mode that vastly increases the chances file output winds up on disk after a crash); OTOH, across platforms the kinds of error msgs we get for malformed mode strings aren't very good:
f = file('oops', 'br') Traceback (most recent call last): File "<stdin>", line 1, in ? IOError: [Errno 0] Error: 'oops'
Radical idea: don't do anything to turn on "universal newlines" -- say it's just what "text mode" means in Python. Then you only have to worry about picking a letter to turn it off <wink>.
Radical idea: don't do anything to turn on "universal newlines" -- say it's just what "text mode" means in Python. Then you only have to worry about picking a letter to turn it off <wink>.
That would be my choice. KISS. --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Guido van Rossum
-
Jack Jansen
-
Tim Peters