Paul Moore wrote: > On 3 April 2018 at 17:54, Peter Otten <__pete...@web.de> wrote: >> I think the culprit is io.open() rather than the logging module. Why does >> >>>>> io.open("/dev/stderr", "a") >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> OSError: [Errno 29] Illegal seek >> >> even try to seek()? > > Because it's append mode so it needs to go to the end?
I expected that to be handled by the C library, and in C there is no error: $ cat open_stderr_in_appendmode.c #include <stdio.h> main() { FILE * stderr = fopen("/dev/stderr", "a"); if (stderr == 0) { printf("failed\n"); } else { printf("succeded\n"); fprintf(stderr, "\nthis goes to stderr\n"); fclose(stderr); } } $ gcc open_stderr_in_appendmode.c $ ./a.out succeded this goes to stderr The same goes for Py2's built-in and codecs.open(): $ python Python 2.7.6 (default, Nov 23 2017, 15:49:48) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import codecs >>> import io >>> with open("/dev/stderr", "a") as f: f.write("works\n") ... works >>> with codecs.open("/dev/stderr", "a") as f: f.write("works\n") ... works >>> with io.open("/dev/stderr", "a") as f: f.write("works\n") ... Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 29] Illegal seek >>> So io.open() really seems to do its own thing, and differently. -- https://mail.python.org/mailman/listinfo/python-list