Skip to content

Commit edc8f13

Browse files
committed
Add directory which contains known ref leaks. Some of these are likely to be system dependent (like test_gestalt).
1 parent 99b4ee6 commit edc8f13

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

Lib/test/leakers/README

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
This directory contains test cases that are known to leak references.
2+
The idea is that you can import these modules while in the interpreter
3+
and call the leak function repeatedly. This will only be helpful if
4+
the interpreter was built in debug mode. If the total ref count
5+
doesn't increase, the bug has been fixed.
6+
7+
Here's an example interpreter session for test_gestalt which still leaks:
8+
9+
>>> from test.leakers.test_gestalt import leak
10+
[24275 refs]
11+
>>> leak()
12+
[28936 refs]
13+
>>> leak()
14+
[28938 refs]
15+
>>> leak()
16+
[28940 refs]
17+
>>>
18+

Lib/test/leakers/__init__.py

Whitespace-only changes.

Lib/test/leakers/test_gestalt.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import sys
3+
4+
if sys.platform != 'darwin':
5+
raise ValueError, "This test only leaks on Mac OS X'
6+
7+
def leak():
8+
# taken from platform._mac_ver_lookup()
9+
from gestalt import gestalt
10+
import MacOS
11+
12+
try:
13+
gestalt('sysu')
14+
except MacOS.Error:
15+
pass

Lib/test/leakers/test_tee.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# Test case taken from test_itertools
3+
# See http://mail.python.org/pipermail/python-dev/2005-November/058339.html
4+
5+
from itertools import tee
6+
7+
def leak():
8+
def fib():
9+
def yield_identity_forever(g):
10+
while 1:
11+
yield g
12+
def _fib():
13+
for i in yield_identity_forever(head):
14+
yield i
15+
head, tail, result = tee(_fib(), 3)
16+
return result
17+
18+
x = fib()
19+
x.next()

0 commit comments

Comments
 (0)