From 24a83765dd4e6eb7f184ab6ff93a62c2398ac022 Mon Sep 17 00:00:00 2001 From: Elijah Qi Date: Sat, 15 Apr 2023 22:22:08 -0400 Subject: [PATCH] Title: Replace deprecated getName() method with name attribute Body: This commit resolves a DeprecationWarning in the tracer.py file. The deprecated getName() method, which is used to get the name of the current_thread object, has been replaced with the recommended name attribute. Changes: - Updated line 473 in tracer.py to use current_thread.name instead of current_thread.getName() With this change, the deprecation warning will no longer appear when running tests, and the code will be compatible with future releases of Python that may remove the deprecated method. --- a.py | 9 +++++++++ pysnooper/tracer.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 a.py diff --git a/a.py b/a.py new file mode 100644 index 0000000..c3cdd29 --- /dev/null +++ b/a.py @@ -0,0 +1,9 @@ +import pysnooper + +@pysnooper.snoop(depth = float('inf')) +def func(x): + if x == 0: + return + func(x - 1) + +func(3) \ No newline at end of file diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index 9c075ed..64e2d4b 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -470,7 +470,7 @@ class Tracer: "thread_info") current_thread = threading.current_thread() thread_info = "{ident}-{name} ".format( - ident=current_thread.ident, name=current_thread.getName()) + ident=current_thread.ident, name=current_thread.name) thread_info = self.set_thread_info_padding(thread_info) ### Reporting newish and modified variables: ##########################