@@ -17,23 +17,52 @@ def __init__(self, *args):
17
17
self .header = "test_stream.hpp"
18
18
self .config .cflags = "-std=c++11"
19
19
20
- def test_stream_non_copyable (self ):
20
+ def test_infinite_recursion_base_classes (self ):
21
21
"""
22
22
Test find_noncopyable_vars
23
23
24
24
See #71
25
25
26
- find_noncopyable_vars is throwing:
26
+ find_noncopyable_vars was throwing:
27
27
RuntimeError: maximum recursion depth exceeded while
28
28
calling a Python object
29
29
"""
30
30
decls = parser .parse ([self .header ], self .config )
31
31
global_ns = declarations .get_global_namespace (decls )
32
32
33
+ # Description of the problem (before the fix):
34
+ # find_noncopyable_vars (on Child class) looks up the variables,
35
+ # and finds aBasePtr2 (a pointer to the Base2 class).
36
+ # Then it looks recursively at the base classes of Base2, and finds
37
+ # Base1. Then, it looks up the variables from Base, to check if Base1
38
+ # is non copyable. It finds another aBasePtr2 variable, which leads to
39
+ # a new check of Base2; this recurses infinitely.
40
+ test_ns = global_ns .namespace ('Test1' )
41
+ cls = test_ns .class_ ('Child' )
42
+ declarations .type_traits_classes .find_noncopyable_vars (cls )
43
+
44
+ def test_infinite_recursion_sstream (self ):
45
+ """
46
+ Test find_noncopyable_vars
47
+
48
+ See #71
49
+
50
+ find_noncopyable_vars was throwing:
51
+ RuntimeError: maximum recursion depth exceeded while
52
+ calling a Python object
53
+ """
54
+ decls = parser .parse ([self .header ], self .config )
55
+ global_ns = declarations .get_global_namespace (decls )
56
+
57
+ # Real life example of the bug. This leads to a similar error,
58
+ # but the situation is more complex as there are multiple
59
+ # classes that are related the one to the others
60
+ # (basic_istream, basic_ios, ios_base, ...)
33
61
test_ns = global_ns .namespace ('Test2' )
34
62
cls = test_ns .class_ ('FileStreamDataStream' )
35
63
declarations .type_traits_classes .find_noncopyable_vars (cls )
36
64
65
+
37
66
def create_suite ():
38
67
suite = unittest .TestSuite ()
39
68
suite .addTest (unittest .makeSuite (Test ))
0 commit comments