MCPcopy Index your code
hub / github.com/python/cpython / local

Class local

Lib/_threading_local.py:82–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81
82class local:
83 __slots__ = '_local__impl', '__dict__'
84
85 def __new__(cls, /, *args, **kw):
86 if (args or kw) and (cls.__init__ is object.__init__):
87 raise TypeError("Initialization arguments are not supported")
88 self = object.__new__(cls)
89 impl = _localimpl()
90 impl.localargs = (args, kw)
91 impl.locallock = RLock()
92 object.__setattr__(self, '_local__impl', impl)
93 # We need to create the thread dict in anticipation of
94 # __init__ being called, to make sure we don't call it
95 # again ourselves.
96 impl.create_dict()
97 return self
98
99 def __getattribute__(self, name):
100 with _patch(self):
101 return object.__getattribute__(self, name)
102
103 def __setattr__(self, name, value):
104 if name == '__dict__':
105 raise AttributeError(
106 "%r object attribute '__dict__' is read-only"
107 % self.__class__.__name__)
108 with _patch(self):
109 return object.__setattr__(self, name, value)
110
111 def __delattr__(self, name):
112 if name == '__dict__':
113 raise AttributeError(
114 "%r object attribute '__dict__' is read-only"
115 % self.__class__.__name__)
116 with _patch(self):
117 return object.__delattr__(self, name)
118
119
120from threading import current_thread, RLock

Callers 2

threading.pyFile · 0.90
_mktimeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…