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.
This commit is contained in:
Elijah Qi 2023-04-15 22:22:08 -04:00
parent b9f35dbcb2
commit 24a83765dd
2 changed files with 10 additions and 1 deletions

9
a.py Normal file
View file

@ -0,0 +1,9 @@
import pysnooper
@pysnooper.snoop(depth = float('inf'))
def func(x):
if x == 0:
return
func(x - 1)
func(3)

View file

@ -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: ##########################