
[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>.