Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197866

open: 'ascii', 'backslashreplace' not behaving as expected - why?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Veek M <veekjunk@foobar.com>
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> (permalink)
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

Show key headers only | View raw


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 ?

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 00:38 +0000
  Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-08-08 01:19 +0000
    Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:22 +0000
      Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:25 +0000
        Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Veek M <veekjunk@foobar.com> - 2026-08-08 04:33 +0000
          Re: open: 'ascii', 'backslashreplace' not behaving as expected - why? Greg Ewing <greg.ewing@canterbury.ac.nz> - 2026-08-10 12:08 +1200

csiph-web