| 80 | |
| 81 | |
| 82 | class 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 | |
| 120 | from threading import current_thread, RLock |
no outgoing calls
no test coverage detected
searching dependent graphs…