@@ -78,24 +78,19 @@ def ok_move(o):
7878 return True
7979 return False
8080
81+ def check (a , args ):
82+ # rc(args) == 3 because we need to know that the args list is moved into the thread too
83+ # rc = 3 because:
84+ # 1. ref to args in rc
85+ # 2. ref to args on this frame
86+ # 3. ref to args on the calling framedef check(a, args):
87+ if not ok_share (a ) or (ok_move (a ) and rc (args ) == 3 ):
88+ raise RuntimeError ("Thread was passed an object which was neither immutable, a cown, or a unique region" )
8189 if kwargs is None :
8290 for a in args :
83- # rc(args) == 3 because we need to know that the args list is moved into the thread too
84- # rc = 3 because:
85- # 1. ref to args in rc
86- # 2. ref to args on this frame
87- # 3. ref to args on the calling frame
88- if not (ok_share (a ) or (ok_move (a ) and rc (args ) == 3 )):
89- raise RuntimeError ("Thread was passed an object which was neither immutable, a cown, or a unique region" )
91+ check (a , args )
9092 return Thread (group , target , name , args , daemon )
9193 else :
9294 for k in kwargs :
93- # rc(args) == 3 because we need to know that keyword dict is moved into the thread too
94- # rc = 3 because:
95- # 1. ref to kwargs in rc
96- # 2. ref to kwargs on this frame
97- # 3. ref to kwargs on the calling frame
98- v = kwargs [k ]
99- if not (ok_share (v ) or (ok_move (v ) and rc (kwargs ) == 3 )):
100- raise RuntimeError ("Thread was passed an object which was neither immutable, a cown, or a unique region" )
95+ check (k , kwargs )
10196 return Thread (group , target , name , kwargs , daemon )
0 commit comments