1# ticket: 430
2
3__doc__ = u"""
4>>> sorted( get_locals(1,2,3, k=5) .items())
5[('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)]
6
7>>> sorted(get_locals_items(1,2,3, k=5))
8[('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)]
9
10>>> sorted(get_locals_items_listcomp(1,2,3, k=5))
11[('args', (2, 3)), ('kwds', {'k': 5}), ('x', 1), ('y', 'hi'), ('z', 5)]
12"""
13
14def get_locals(x, *args, **kwds):
15    cdef int z = 5
16    y = "hi"
17    return locals()
18
19def get_locals_items(x, *args, **kwds):
20    cdef int z = 5
21    y = "hi"
22    return locals().items()
23
24def get_locals_items_listcomp(x, *args, **kwds):
25    # FIXME: 'item' should *not* appear in locals() yet, as locals()
26    # is evaluated before assigning to item !
27    cdef int z = 5
28    y = "hi"
29    return [ item for item in locals().items() ]
30
31def sorted(it):
32    l = list(it)
33    l.sort()
34    return l
35