From c7275b25a8f0be3ed532450c1ff26adb9fcd1332 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Sun, 16 Nov 2025 14:20:03 -0800 Subject: [PATCH] fix: redirect to stderr for xauthority-related errors Throughout this codebase, the print function is being invoked for debugging purposes both within the examples directory and the python module itself. The print function being present in the latter is not only questionable and poor practice for logging error messages, but problematic for applications that read and depend on data from stdout in the event that an xauthority-related error occurs. As an improvement and simple fix, redirect the error message to stderr instead of stdout when invoking print. --- Xlib/xauth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index 303bd49..2a3f2cc 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -21,6 +21,7 @@ import os import struct +import sys from Xlib import X, error @@ -89,10 +90,10 @@ def __init__(self, filename = None): self.entries.append((family, addr, num, name, data)) except struct.error: - print("Xlib.xauth: warning, failed to parse part of xauthority file {0}, aborting all further parsing".format(filename)) + print("Xlib.xauth: warning, failed to parse part of xauthority file {0}, aborting all further parsing".format(filename), file=sys.stderr) if len(self.entries) == 0: - print("Xlib.xauth: warning, no xauthority details available") + print("Xlib.xauth: warning, no xauthority details available", file=sys.stderr) # raise an error? this should get partially caught by the XNoAuthError in get_best_auth.. def __len__(self):