----- Original Message -----
From: "Paul G"
----- Original Message ----- From: "Jean-Paul Calderone"
To: "Twisted general discussion" Sent: Saturday, December 31, 2005 6:46 PM Subject: Re: [Twisted-Python] Re: plus mode was Re: how winnt fileops workandwhat to do about it On Sat, 31 Dec 2005 18:12:06 -0500, James Y Knight
wrote: On Dec 31, 2005, at 4:57 PM, Paul G wrote:
oh, it makes perfect sense to have a workaround in twisted, i'm not suggesting otherwise. however, it should be just that - a temporary workaround until cpython has a fix for the issue, because (outside of the offending libc implementation), that is the right place to fix it.
As I wrote in the bug report:
It's not a python bug except perhaps that python should raise an exception. Doing a read and write without a seek in between is illegal in C.
"ANSI C requires that a file positioning function intervene between output and input, unless an input operation encounters end-of-file."
I am against including any sort of workaround besides raising an exception if the situation occurs. And I don't think even that is particularly warranted.
Thanks for pointing this out. The immediate fix is now obvious: the test needs to change. It _might_ be nice to have an assertion for this behavior, but I'm not about to add a file wrapper just for this (if all of Twisted used FilePath, instead of opening files directly, I might grant more weight to this, but since it doesn't...).
are we sure streams are only used with File objects FilePath gives us?
the relevant snippet of an ltrace python -c "f=open('/etc/hosts/', 'r+')" --- __ctype_b_loc(0x40115740, 0x40115548, 5, 0x08112740, 0) = 0x401138e4 malloc(11) = 0x0814cd18 realloc(NULL, 16) = 0x08157910 memcpy(0x0814cd18, "/etc/hosts", 11) = 0x0814cd18 free(0x08157910) = <void> __ctype_b_loc(0x40115740, 0x40115548, 0, 0, 0) = 0x401138e4 memcpy(0x40160c74, "r+", 3) = 0x40160c74 strchr("r+", 'b') = NULL strchr("r+", 'U') = NULL __errno_location() = 0x401138e0 fopen64("/etc/hosts", "r+") = 0x08175538 --- sure enough, fopen. -p