comparison mercurial/crecord.py @ 45011:1bab6b61b62b stable

curses: do not initialize LC_ALL to user settings (issue6358) 701341f57ceb moved the setlocale() call to right before curses was used. This didn’t fully solve the problem it was supposed to solve (locale-dependent functions, like date formatting/parsing and str methods on Python 2), but only postponed it. Initializing LC_CTYPE seems to be sufficient for curses to work correctly. Therefore LC_CTYPE is set while curses is used and reset afterwards. Some locale-dependent str methods might behave differently on Python 2 while curses is used, but that shouldn’d be a problem.
author Manuel Jacob <me@manueljacob.de>
date Sun, 28 Jun 2020 18:02:45 +0200
parents d3f776c4760e
children 4a503c1b664a
comparison
equal deleted inserted replaced
45004:2632c1ed8f34 45011:1bab6b61b62b
8 # This code is based on the Mark Edgington's crecord extension. 8 # This code is based on the Mark Edgington's crecord extension.
9 # (Itself based on Bryan O'Sullivan's record extension.) 9 # (Itself based on Bryan O'Sullivan's record extension.)
10 10
11 from __future__ import absolute_import 11 from __future__ import absolute_import
12 12
13 import locale
14 import os 13 import os
15 import re 14 import re
16 import signal 15 import signal
17 16
18 from .i18n import _ 17 from .i18n import _
572 curses interface to get selection of chunks, and mark the applied flags 571 curses interface to get selection of chunks, and mark the applied flags
573 of the chosen chunks. 572 of the chosen chunks.
574 """ 573 """
575 ui.write(_(b'starting interactive selection\n')) 574 ui.write(_(b'starting interactive selection\n'))
576 chunkselector = curseschunkselector(headerlist, ui, operation) 575 chunkselector = curseschunkselector(headerlist, ui, operation)
577 # This is required for ncurses to display non-ASCII characters in
578 # default user locale encoding correctly. --immerrr
579 locale.setlocale(locale.LC_ALL, '')
580 origsigtstp = sentinel = object() 576 origsigtstp = sentinel = object()
581 if util.safehasattr(signal, b'SIGTSTP'): 577 if util.safehasattr(signal, b'SIGTSTP'):
582 origsigtstp = signal.getsignal(signal.SIGTSTP) 578 origsigtstp = signal.getsignal(signal.SIGTSTP)
583 try: 579 try:
584 curses.wrapper(chunkselector.main) 580 with util.with_lc_ctype():
581 curses.wrapper(chunkselector.main)
585 if chunkselector.initexc is not None: 582 if chunkselector.initexc is not None:
586 raise chunkselector.initexc 583 raise chunkselector.initexc
587 # ncurses does not restore signal handler for SIGTSTP 584 # ncurses does not restore signal handler for SIGTSTP
588 finally: 585 finally:
589 if origsigtstp is not sentinel: 586 if origsigtstp is not sentinel: