File tree 2 files changed +9
-15
lines changed
2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -49,28 +49,24 @@ class DomainRequirementFailed(Exception):
49
49
class Fragment :
50
50
@staticmethod
51
51
def get (obj , platform ):
52
- code = None
53
52
origins = []
53
+ returned_by = ""
54
54
while True :
55
55
if isinstance (obj , Fragment ):
56
56
if hasattr (obj , "origins" ):
57
57
obj .origins = tuple (origins )
58
58
return obj
59
59
elif isinstance (obj , Elaboratable ):
60
60
code = obj .elaborate .__code__
61
+ returned_by = f", returned by { code .co_filename } :{ code .co_firstlineno } "
61
62
UnusedElaboratable ._MustUse__silence = False
62
63
obj ._MustUse__used = True
63
64
new_obj = obj .elaborate (platform )
64
65
else :
65
- raise TypeError (f"Object { obj !r} is not an 'Elaboratable' nor 'Fragment'" )
66
+ raise TypeError (
67
+ f"Object { obj !r} is not an 'Elaboratable' nor 'Fragment'{ returned_by } " )
66
68
if new_obj is obj :
67
- raise RecursionError (f"Object { obj !r} elaborates to itself" )
68
- if new_obj is None and code is not None :
69
- warnings .warn_explicit (
70
- message = ".elaborate() returned None; missing return statement?" ,
71
- category = UserWarning ,
72
- filename = code .co_filename ,
73
- lineno = code .co_firstlineno )
69
+ raise RecursionError (f"Object { obj !r} elaborates to itself{ returned_by } " )
74
70
origins .append (obj )
75
71
obj = new_obj
76
72
Original file line number Diff line number Diff line change @@ -31,15 +31,13 @@ def test_get_wrong_none(self):
31
31
r"^Object None is not an 'Elaboratable' nor 'Fragment'$" ):
32
32
Fragment .get (None , platform = None )
33
33
34
- with self .assertWarnsRegex (UserWarning ,
35
- r"^\.elaborate\(\) returned None; missing return statement\?$" ):
36
- with self .assertRaisesRegex (TypeError ,
37
- r"^Object None is not an 'Elaboratable' nor 'Fragment'$" ):
38
- Fragment .get (ElaboratesToNone (), platform = None )
34
+ with self .assertRaisesRegex (TypeError ,
35
+ r"^Object None is not an 'Elaboratable' nor 'Fragment', returned by .+?:19$" ):
36
+ Fragment .get (ElaboratesToNone (), platform = None )
39
37
40
38
def test_get_wrong_self (self ):
41
39
with self .assertRaisesRegex (RecursionError ,
42
- r"^Object <.+?ElaboratesToSelf.+?> elaborates to itself$" ):
40
+ r"^Object <.+?ElaboratesToSelf.+?> elaborates to itself, returned by .+?:24 $" ):
43
41
Fragment .get (ElaboratesToSelf (), platform = None )
44
42
45
43
You can’t perform that action at this time.
0 commit comments