Joel Barry added the comment: I was suggesting that the openhook could somehow be applied to a *reopening* of sys.stdin. Something like this:
326c326,329 < self._file = sys.stdin --- > if self._openhook: > self._file = self._openhook(self._filename, > self._mode) > else: > self._file = sys.stdin But this won't work because self._filename here is '<stdin>' which isn't a real filename. In conjunction with a change to my hook: def hook(filename, mode): if filename == '<stdin>': return io.TextIOWrapper(sys.stdin.buffer, errors='replace') return open(filename, mode, errors='replace') things would work, but this is a bit awkward. This works for me without changing my hook: 326c326,329 < self._file = sys.stdin --- > if self._openhook: > self._file = self._openhook('/dev/stdin', self._mode) > else: > self._file = sys.stdin but I realize that using /dev/stdin is not portable. The desired outcome is really just to control Unicode behavior from stdin, not necessary the ability to provide a generic hook. Adding an 'errors' keyword to apply to stdin would solve my case, but if you open up 'errors', someone may also want 'encoding', and the others, which is why it would be nicer if this could somehow be solved with the existing openhook interface. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26756> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com