Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Veek M Newsgroups: comp.lang.python Subject: open: 'ascii', 'backslashreplace' not behaving as expected - why? Date: Sat, 8 Aug 2026 00:38:24 -0000 (UTC) Organization: A noiseless patient Spider Lines: 10 Message-ID: <1155tpv$13on7$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 08 Aug 2026 00:38:24 +0000 (UTC) Injection-Info: dont-email.me; logging-data="1172199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Aim/9V6cXNLeX5HNzCKtR"; posting-host="ff84599c90f2ba480191f847ccd63d2e" User-Agent: Pan/0.154 (Izium; 517acf4) Cancel-Lock: sha1:PFmx75s16vXWDSz5u3WN/YmgBsE= sha256:76t4Ebam7lfhvAXc8KVxDWGgjbWMq9jCsagzxbY7/Wg= sha1:WXlANkkZN0RjuJJ2+oIZICCuPPA= sha256:5tdhuXXfTKjO7a4U7N+4f/Ezj+v+LRs9XbVtnYeTz2k= Xref: csiph.com comp.lang.python:197866 So in kate, i Ctrl-Shift-U and type ffff to enter a unicode codepoint of 0xffff. Then at the REPL prompt i do fh = open('/tmp/x', 'rt', -1, 'ascii', 'backslashreplace', None) and i get fh.readline() '\\xef\\xbf\\xbf\n' Since I wrote two bytes 0xff and 0xff into Kate - why am i getting 0xef 0xbf and 0xbf ?