Make scripts compatible with Python 3.13
Reason why this change is needed
Python 3.13 has been released in October 2024 and is the current major release of Python 3. The scripts should be compatible with the latest release.
Description of the change
The only required change is in the logging code where two functions were renamed and they were changed slightly to become more reliable, cf. https://github.com/python/cpython/commit/74723e11109a320e628898817ab449b3dad9ee96.
(In the long term, one may want to refactor the logging code to use the context manager available in the Handler
class.)