Skip Montanaro wrote: > I've encountered a problem in an application I'm porting from Python > 2.7 to 3.6. The logginng.FileHandler class likes "/dev/stderr" as a > destination in Python 2, but complains in Python 3. > > Python 2.7.14: > >>>> import logging >>>> logging.FileHandler("/dev/stderr") > <logging.FileHandler object at 0x7fbbba9bbdd0> > > Python 3.6.4: > >>>> import logging >>>> logging.FileHandler("/dev/stderr") > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File > "/home/skip/miniconda3/envs/python3/lib/python3.6/logging/__init__.py", > line 1030, in __init__ > StreamHandler.__init__(self, self._open()) > File > "/home/skip/miniconda3/envs/python3/lib/python3.6/logging/__init__.py", > line 1059, in _open > return open(self.baseFilename, self.mode, encoding=self.encoding) > OSError: [Errno 29] Illegal seek > > I can see how to work around the error, pass mode="w" when passing > /dev/{stdout,stderr} to the constructor. Shouldn't that bit of > ugliness be hidden in the logging module?
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()? -- https://mail.python.org/mailman/listinfo/python-list