You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internally, Process.as_dict uses dir() builtin in order to fetch all attribute/method names of the Process class in order to return their value as a dict. Unfortunately this means that if the user attaches a new name to the Process instance that will be returned as well:
import psutil
p = psutil.Process()
p.foo = '1'
print 'foo' in p.as_dict()
Even worse, if the new name refers to a callable object, that will be called. The solution is to execute dir(Process) at import time, store the names in a global variable and have as_dict rely on it.
The text was updated successfully, but these errors were encountered:
Internally,
Process.as_dict
usesdir()
builtin in order to fetch all attribute/method names of theProcess
class in order to return their value as a dict. Unfortunately this means that if the user attaches a new name to theProcess
instance that will be returned as well:Even worse, if the new name refers to a callable object, that will be called. The solution is to execute
dir(Process)
at import time, store the names in a global variable and haveas_dict
rely on it.The text was updated successfully, but these errors were encountered: