annotate Lib/test/inspect_fodder.py @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 39d0dfa5808c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
34151
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
1 # line 1
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
2 'A module docstring.'
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
3
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
4 import sys, inspect
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
5 # line 5
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
6
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
7 # line 7
41717
9ad84070b22d Merged revisions 55328-55341 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 34151
diff changeset
8 def spam(a, b, c, d=3, e=4, f=5, *g, **h):
34151
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
9 eggs(b + d, c + f)
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
10
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
11 # line 11
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
12 def eggs(x, y):
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
13 "A docstring."
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
14 global fr, st
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
15 fr = inspect.currentframe()
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
16 st = inspect.stack()
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
17 p = x
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
18 q = y / 0
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
19
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
20 # line 20
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
21 class StupidGit:
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
22 """A longer,
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
23
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
24 indented
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
25
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
26 docstring."""
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
27 # line 27
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
28
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
29 def abuse(self, a, b, c):
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
30 """Another
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
31
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
32 \tdocstring
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
33
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
34 containing
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
35
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
36 \ttabs
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
37 \t
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
38 """
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
39 self.argue(a, b, c)
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
40 # line 40
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
41 def argue(self, a, b, c):
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
42 try:
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
43 spam(a, b, c)
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
44 except:
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
45 self.ex = sys.exc_info()
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
46 self.tr = inspect.trace()
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
47
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
48 # line 48
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
49 class MalodorousPervert(StupidGit):
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
50 pass
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
51
85540
39d0dfa5808c Issue #18830: inspect.getclasstree() no more produces duplicated entries even
Serhiy Storchaka <storchaka@gmail.com>
parents: 41717
diff changeset
52 Tit = MalodorousPervert
39d0dfa5808c Issue #18830: inspect.getclasstree() no more produces duplicated entries even
Serhiy Storchaka <storchaka@gmail.com>
parents: 41717
diff changeset
53
34151
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
54 class ParrotDroppings:
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
55 pass
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
56
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
57 class FesteringGob(MalodorousPervert, ParrotDroppings):
de4701fc176f Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff changeset
58 pass