[PATCH 1 of 2] visdiff: use thread.daemon instead of deprecated Thread.setDaemon()

3 views
Skip to first unread message

Antonio Muci

unread,
Dec 3, 2025, 4:37:31 PMDec 3
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1764794658 -3600
# Wed Dec 03 21:44:18 2025 +0100
# Branch stable
# Node ID 8c15c3614dd846be8951a23a912a24dbf9a97be6
# Parent e6e24115b428ac3bf18e1d342801395d94163334
visdiff: use thread.daemon instead of deprecated Thread.setDaemon()

Before this change, launching thg with:

```
python3.14 -X tracemalloc -Wall ./thg
```

and clicking on a changed file on some past commit would open the visual diff
program, and trigger the following error:

```
<BASE>/tortoisehg/hgqt/visdiff.py:487: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
thread.setDaemon(True)
```

According to documentation at
https://docs.python.org/3.14/library/threading.html#threading.Thread.setDaemon,
the Thread.setDaemon() setter has been deprecated in python 3.10 (oct 2021).

The documentation suggests to "use it directly as a property instead". Indeed,
this gets rid of the warning.

diff --git a/tortoisehg/hgqt/visdiff.py b/tortoisehg/hgqt/visdiff.py
--- a/tortoisehg/hgqt/visdiff.py
+++ b/tortoisehg/hgqt/visdiff.py
@@ -484,7 +484,7 @@ def visual_diff(ui: uimod.ui, repo: loca
# We are not the main application, so this must be done in a
# background thread
thread = threading.Thread(target=dodiff, name='visualdiff')
- thread.setDaemon(True)
+ thread.daemon = True
thread.start()

class FileSelectionDialog(QDialog):

Antonio Muci

unread,
Dec 3, 2025, 4:37:32 PMDec 3
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1764794815 -3600
# Wed Dec 03 21:46:55 2025 +0100
# Branch stable
# Node ID d0c1d08b4415bdd4170ca9ed57759dba5526c1bc
# Parent 8c15c3614dd846be8951a23a912a24dbf9a97be6
w32ill: visdiff: use thread.daemon instead of deprecated Thread.setDaemon()

This is the same kind of change done in the previous commit. I have no quick way
to force program execution through this path, but the future-proofing advantage
seems worth it.

diff --git a/tortoisehg/util/win32ill.py b/tortoisehg/util/win32ill.py
--- a/tortoisehg/util/win32ill.py
+++ b/tortoisehg/util/win32ill.py
@@ -179,7 +179,7 @@ class messageserver:
def __init__(self, logfile: Optional[BinaryIO]) -> None:
self._logfile = logfile
self._thread = threading.Thread(target=self._mainloop)
- self._thread.setDaemon(True) # skip global join before atexit
+ self._thread.daemon = True # skip global join before atexit
self._wndcreated = threading.Event()
self._hwnd = None
self._wndclass = wc = _WNDCLASS()

Yuya Nishihara

unread,
Dec 4, 2025, 7:08:19 AMDec 4
to 'Antonio Muci' via TortoiseHg Developers, a....@inwind.it
On Wed, 03 Dec 2025 22:37:27 +0100, 'Antonio Muci' via TortoiseHg
Developers wrote:
> # HG changeset patch
> # User Antonio Muci <a....@inwind.it>
> # Date 1764794658 -3600
> # Wed Dec 03 21:44:18 2025 +0100
> # Branch stable
> # Node ID 8c15c3614dd846be8951a23a912a24dbf9a97be6
> # Parent e6e24115b428ac3bf18e1d342801395d94163334
> visdiff: use thread.daemon instead of deprecated Thread.setDaemon()

Queued, thanks.
Reply all
Reply to author
Forward
0 new messages