Mercurial > hg
comparison mercurial/crecord.py @ 42659:701341f57ceb stable
curses: do not setlocale() at import time (issue5261)
setlocale() can break date formatting/parsing functions because they are
locale dependent. We should avoid doing setlocale() as possible.
This patch moves setlocale() just before curses.wrapper(), which function
is documented to "initialize curses." I don't know the details about the
curses initialization, but I *think* this would work as well.
Maybe we can extract a curses setup function later.
https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-February/128788.html
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 25 Jul 2019 21:28:29 +0900 |
parents | 9ac1a5a4a64f |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
42649:7fae3b0bd893 | 42659:701341f57ceb |
---|---|
26 ) | 26 ) |
27 from .utils import ( | 27 from .utils import ( |
28 stringutil, | 28 stringutil, |
29 ) | 29 ) |
30 stringio = util.stringio | 30 stringio = util.stringio |
31 | |
32 # This is required for ncurses to display non-ASCII characters in default user | |
33 # locale encoding correctly. --immerrr | |
34 locale.setlocale(locale.LC_ALL, r'') | |
35 | 31 |
36 # patch comments based on the git one | 32 # patch comments based on the git one |
37 diffhelptext = _("""# To remove '-' lines, make them ' ' lines (context). | 33 diffhelptext = _("""# To remove '-' lines, make them ' ' lines (context). |
38 # To remove '+' lines, delete them. | 34 # To remove '+' lines, delete them. |
39 # Lines starting with # will be removed from the patch. | 35 # Lines starting with # will be removed from the patch. |
528 curses interface to get selection of chunks, and mark the applied flags | 524 curses interface to get selection of chunks, and mark the applied flags |
529 of the chosen chunks. | 525 of the chosen chunks. |
530 """ | 526 """ |
531 ui.write(_('starting interactive selection\n')) | 527 ui.write(_('starting interactive selection\n')) |
532 chunkselector = curseschunkselector(headerlist, ui, operation) | 528 chunkselector = curseschunkselector(headerlist, ui, operation) |
529 # This is required for ncurses to display non-ASCII characters in | |
530 # default user locale encoding correctly. --immerrr | |
531 locale.setlocale(locale.LC_ALL, r'') | |
533 origsigtstp = sentinel = object() | 532 origsigtstp = sentinel = object() |
534 if util.safehasattr(signal, 'SIGTSTP'): | 533 if util.safehasattr(signal, 'SIGTSTP'): |
535 origsigtstp = signal.getsignal(signal.SIGTSTP) | 534 origsigtstp = signal.getsignal(signal.SIGTSTP) |
536 try: | 535 try: |
537 curses.wrapper(chunkselector.main) | 536 curses.wrapper(chunkselector.main) |