forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (18 loc) · 649 Bytes
/
Copy pathtest.py
File metadata and controls
25 lines (18 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#This is prone to strange side effects and race conditions.
class MutatingDescriptor(object):
def __init__(self, func):
self.my_func = func
def __get__(self, obj, obj_type):
#Modified state is visible to all instances.
self.my_obj = obj
return self
def __call__(self, *args):
return self.my_func(self.my_obj, *args)
#Not call from __get__, __set__ or __delete__
def ok(self, func):
self.my_func = func
def __set__(self, obj, value):
self.not_ok(value)
def not_ok(self, value):
#Modified state is visible to all instances.
self.my_obj = value