Re: [Python-Dev] Patch submitted for cross-platform newline support

Recently, "Tim Peters" <tim@zope.com> said:
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]
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:
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/)

[Jack Jansen]
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:
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