const.py, rigo: remove remaining Python 2 dead code

Simplify const_isfileobj(), const_isnumber(), const_debug_write()
and remove unreachable code in rigo/rigo/utils.py::prepare_markup().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mario Fetka
2026-06-26 11:52:21 +02:00
parent 7072c00a77
commit fc1d71db8e
2 changed files with 6 additions and 20 deletions

View File

@@ -1439,20 +1439,14 @@ def const_isfileobj(obj):
"""
Return whether obj is a file object
"""
if const_is_python3():
import io
return isinstance(obj, io.IOBase)
else:
return isinstance(obj, file)
import io
return isinstance(obj, io.IOBase)
def const_isnumber(obj):
"""
Return whether obj is an int, long object.
"""
if const_is_python3():
return isinstance(obj, int)
else:
return isinstance(obj, (int, long,))
return isinstance(obj, int)
def const_cmp(a, b):
"""
@@ -1575,12 +1569,9 @@ def const_debug_write(identifier, msg, force = False, stdout=None):
teal(repr(current_thread.daemon)), darkgreen(repr(time.time())),
darkred(identifier),)
with _DEBUG_W_LOCK:
if const_is_python3():
stdout.buffer.write(
const_convert_to_rawstring(th_identifier) + \
b" " + const_convert_to_rawstring(msg) + b"\n")
else:
stdout.write("%s: %s" % (th_identifier, msg + "\n"))
stdout.buffer.write(
const_convert_to_rawstring(th_identifier) + \
b" " + const_convert_to_rawstring(msg) + b"\n")
stdout.flush()
def const_get_caller():

View File

@@ -204,9 +204,4 @@ def prepare_markup(text):
"""
Convert text to raw bytestring to make GTK3 happy.
"""
return text # str()-strings just work
if const_isunicode(text):
return \
const_convert_to_rawstring(
text, from_enctype=etpConst['conf_encoding'])
return text