mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-133575: eliminate legacy checks in Lib/curses/__init__.py
(#133576)
This commit is contained in:
parent
d9b0b07098
commit
a054af6edd
1 changed files with 7 additions and 10 deletions
|
@ -30,9 +30,8 @@ def initscr():
|
||||||
fd=_sys.__stdout__.fileno())
|
fd=_sys.__stdout__.fileno())
|
||||||
stdscr = _curses.initscr()
|
stdscr = _curses.initscr()
|
||||||
for key, value in _curses.__dict__.items():
|
for key, value in _curses.__dict__.items():
|
||||||
if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
|
if key.startswith('ACS_') or key in ('LINES', 'COLS'):
|
||||||
setattr(curses, key, value)
|
setattr(curses, key, value)
|
||||||
|
|
||||||
return stdscr
|
return stdscr
|
||||||
|
|
||||||
# This is a similar wrapper for start_color(), which adds the COLORS and
|
# This is a similar wrapper for start_color(), which adds the COLORS and
|
||||||
|
@ -41,12 +40,9 @@ def initscr():
|
||||||
|
|
||||||
def start_color():
|
def start_color():
|
||||||
import _curses, curses
|
import _curses, curses
|
||||||
retval = _curses.start_color()
|
_curses.start_color()
|
||||||
if hasattr(_curses, 'COLORS'):
|
curses.COLORS = _curses.COLORS
|
||||||
curses.COLORS = _curses.COLORS
|
curses.COLOR_PAIRS = _curses.COLOR_PAIRS
|
||||||
if hasattr(_curses, 'COLOR_PAIRS'):
|
|
||||||
curses.COLOR_PAIRS = _curses.COLOR_PAIRS
|
|
||||||
return retval
|
|
||||||
|
|
||||||
# Import Python has_key() implementation if _curses doesn't contain has_key()
|
# Import Python has_key() implementation if _curses doesn't contain has_key()
|
||||||
|
|
||||||
|
@ -85,10 +81,11 @@ def wrapper(func, /, *args, **kwds):
|
||||||
# Start color, too. Harmless if the terminal doesn't have
|
# Start color, too. Harmless if the terminal doesn't have
|
||||||
# color; user can test with has_color() later on. The try/catch
|
# color; user can test with has_color() later on. The try/catch
|
||||||
# works around a minor bit of over-conscientiousness in the curses
|
# works around a minor bit of over-conscientiousness in the curses
|
||||||
# module -- the error return from C start_color() is ignorable.
|
# module -- the error return from C start_color() is ignorable,
|
||||||
|
# unless they are raised by the interpreter due to other issues.
|
||||||
try:
|
try:
|
||||||
start_color()
|
start_color()
|
||||||
except:
|
except _curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return func(stdscr, *args, **kwds)
|
return func(stdscr, *args, **kwds)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue