##// END OF EJS Templates
posix: always seek to EOF when opening a file in append mode...
posix: always seek to EOF when opening a file in append mode Python 3 already does this, so skip it there. Consider the program: #include <stdio.h> int main() { FILE *f = fopen("narf", "w"); fprintf(f, "narf\n"); fclose(f); f = fopen("narf", "a"); printf("%ld\n", ftell(f)); fprintf(f, "troz\n"); printf("%ld\n", ftell(f)); return 0; } on macOS, FreeBSD, and Linux with glibc, this program prints 5 10 but on musl libc (Alpine Linux and probably others) this prints 0 10 By my reading of https://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html this is technically correct, specifically: > Opening a file with append mode (a as the first character in the > mode argument) shall cause all subsequent writes to the file to be > forced to the then current end-of-file, regardless of intervening > calls to fseek(). in other words, the file position doesn't really matter in append-mode files, and we can't depend on it being at all meaningful unless we perform a seek() before tell() after open(..., 'a'). Experimentally after a .write() we can do a .tell() and it'll always be reasonable, but I'm unclear from reading the specification if that's a smart thing to rely on. This matches what we do on Windows and what Python 3 does for free, so let's just be consistent. Thanks to Yuya for the idea.

File last commit:

r41073:d7d3164e stable
r43163:97ada9b8 5.0.2 stable
Show More
phab-conduit.json
72 lines | 2.7 KiB | application/json | JsonLexer
{
"interactions": [
{
"response": {
"status": {
"message": "OK",
"code": 200
},
"headers": {
"content-type": [
"application/json"
],
"date": [
"Fri, 21 Dec 2018 22:19:11 GMT"
],
"x-content-type-options": [
"nosniff"
],
"cache-control": [
"no-store"
],
"strict-transport-security": [
"max-age=0; includeSubdomains; preload"
],
"x-frame-options": [
"Deny"
],
"set-cookie": [
"phsid=A%2Fdv22bpksbdis3vfeksluagfslhfojblbnkro7we4; expires=Wed, 20-Dec-2023 22:19:11 GMT; Max-Age=157680000; path=/; domain=phab.mercurial-scm.org; secure; httponly"
],
"x-xss-protection": [
"1; mode=block"
],
"expires": [
"Sat, 01 Jan 2000 00:00:00 GMT"
],
"transfer-encoding": [
"chunked"
],
"server": [
"Apache/2.4.10 (Debian)"
]
},
"body": {
"string": "{\"result\":{\"data\":[],\"maps\":{},\"query\":{\"queryKey\":null},\"cursor\":{\"limit\":100,\"after\":null,\"before\":null,\"order\":null}},\"error_code\":null,\"error_info\":null}"
}
},
"request": {
"method": "POST",
"headers": {
"accept": [
"application/mercurial-0.1"
],
"content-type": [
"application/x-www-form-urlencoded"
],
"content-length": [
"70"
],
"host": [
"phab.mercurial-scm.org"
],
"user-agent": [
"mercurial/proto-1.0 (Mercurial 4.8.1+564-6f483b107eb5+20181221)"
]
},
"uri": "https://phab.mercurial-scm.org//api/user.search",
"body": "constraints%5BisBot%5D=true&api.token=cli-hahayouwish"
}
}
],
"version": 1
}