##// 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:

r40699:c53f0ead default
r42778:97ada9b8 5.0.2 stable
Show More
test-hgweb-auth.py.out
217 lines | 5.8 KiB | text/plain | TextLexer
/ tests / test-hgweb-auth.py.out
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
*** Test in-uri schemes
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'http://example.org'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
('x', 'x')
URI: http://example.org/foo/bar
('x', 'x')
URI: http://example.org/bar
('x', 'x')
URI: https://example.org/foo
abort
URI: https://example.org/foo/bar
abort
URI: https://example.org/bar
abort
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
abort
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'https://example.org'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
abort
URI: http://example.org/foo/bar
abort
URI: http://example.org/bar
abort
URI: https://example.org/foo
('x', 'x')
URI: https://example.org/foo/bar
('x', 'x')
URI: https://example.org/bar
('x', 'x')
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
('x', 'x')
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'http://example.org', b'x.schemes': b'https'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
('x', 'x')
URI: http://example.org/foo/bar
('x', 'x')
URI: http://example.org/bar
('x', 'x')
URI: https://example.org/foo
abort
URI: https://example.org/foo/bar
abort
URI: https://example.org/bar
abort
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
abort
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'https://example.org', b'x.schemes': b'http'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
abort
URI: http://example.org/foo/bar
abort
URI: http://example.org/bar
abort
URI: https://example.org/foo
('x', 'x')
URI: https://example.org/foo/bar
('x', 'x')
URI: https://example.org/bar
('x', 'x')
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
('x', 'x')
URI: https://y@example.org/bar
abort
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
*** Test separately configured schemes
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'example.org', b'x.schemes': b'http'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
('x', 'x')
URI: http://example.org/foo/bar
('x', 'x')
URI: http://example.org/bar
('x', 'x')
URI: https://example.org/foo
abort
URI: https://example.org/foo/bar
abort
URI: https://example.org/bar
abort
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
abort
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'example.org', b'x.schemes': b'https'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
abort
URI: http://example.org/foo/bar
abort
URI: http://example.org/bar
abort
URI: https://example.org/foo
('x', 'x')
URI: https://example.org/foo/bar
('x', 'x')
URI: https://example.org/bar
('x', 'x')
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
('x', 'x')
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'example.org', b'x.schemes': b'http https'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
('x', 'x')
URI: http://example.org/foo/bar
('x', 'x')
URI: http://example.org/bar
('x', 'x')
URI: https://example.org/foo
('x', 'x')
URI: https://example.org/foo/bar
('x', 'x')
URI: https://example.org/bar
('x', 'x')
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
('x', 'x')
URI: https://y@example.org/bar
abort
Sune Foldager
allow http authentication information to be specified in the configuration
r8333
*** Test prefix matching
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'http://example.org/foo', b'y.prefix': b'http://example.org/bar'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
('x', 'x')
URI: http://example.org/foo/bar
('x', 'x')
URI: http://example.org/bar
('y', 'y')
URI: https://example.org/foo
abort
URI: https://example.org/foo/bar
abort
URI: https://example.org/bar
abort
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
abort
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'http://example.org/foo', b'y.prefix': b'http://example.org/foo/bar'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
('x', 'x')
URI: http://example.org/foo/bar
('y', 'y')
URI: http://example.org/bar
abort
URI: https://example.org/foo
abort
URI: https://example.org/foo/bar
abort
URI: https://example.org/bar
abort
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
abort
URI: https://y@example.org/bar
abort
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.prefix': b'*', b'y.prefix': b'https://example.org/bar'}
Sune Foldager
allow http authentication information to be specified in the configuration
r8333 URI: http://example.org/foo
abort
URI: http://example.org/foo/bar
abort
URI: http://example.org/bar
abort
URI: https://example.org/foo
('x', 'x')
URI: https://example.org/foo/bar
('x', 'x')
URI: https://example.org/bar
('y', 'y')
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: https://x@example.org/bar
('x', 'x')
URI: https://y@example.org/bar
('y', 'y')
*** Test user matching
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.password': b'xpassword', b'x.prefix': b'http://example.org/foo', b'x.username': None}
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: http://y@example.org/foo
('y', 'xpassword')
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.password': b'xpassword', b'x.prefix': b'http://example.org/foo', b'x.username': None, b'y.password': b'ypassword', b'y.prefix': b'http://example.org/foo', b'y.username': b'y'}
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: http://y@example.org/foo
('y', 'ypassword')
Augie Fackler
tests: use stringutil.pprint instead of custom dumper in test-hgweb-auth.py...
r37959 CFG: {b'x.password': b'xpassword', b'x.prefix': b'http://example.org/foo/bar', b'x.username': None, b'y.password': b'ypassword', b'y.prefix': b'http://example.org/foo', b'y.username': b'y'}
Patrick Mezard
hgweb: do not ignore [auth] if url has a username (issue2822)...
r15005 URI: http://y@example.org/foo/bar
('y', 'xpassword')
Patrick Mezard
http: strip credentials from urllib2 manager URIs (issue2885)...
r15024
Matt Harbison
http: allow 'auth.prefix' to have a username consistent with the URI...
r40699 *** Test user matching with name in prefix
CFG: {b'x.password': b'xpassword', b'x.prefix': b'https://example.org/foo', b'x.username': None, b'y.password': b'ypassword', b'y.prefix': b'http://y@example.org/foo', b'y.username': b'y'}
URI: http://y@example.org/foo
('y', 'ypassword')
CFG: {b'y.password': b'ypassword', b'y.prefix': b'http://z@example.org/foo', b'y.username': b'y'}
URI: http://y@example.org/foo
abort
CFG: {b'y.password': b'ypassword', b'y.prefix': b'http://z@example.org/foo'}
URI: http://y@example.org/foo
abort
CFG: {b'y.password': b'ypassword', b'y.prefix': b'http://y@example.org/foo', b'y.username': b'z'}
URI: http://y@example.org/foo
abort
CFG: {b'y.password': b'ypassword', b'y.prefix': b'http://y@example.org/foo'}
URI: http://y@example.org/foo
('y', 'ypassword')
CFG: {b'y.password': b'ypassword', b'y.prefix': b'http://y@example.org/foo'}
URI: http://example.org/foo
abort
Patrick Mezard
http: strip credentials from urllib2 manager URIs (issue2885)...
r15024 *** Test urllib2 and util.url
URIs: http://user@example.com:8080/foo http://example.com:8080/foo
('user', '')