File: custom_python_leaky_class_vars.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (25 lines) | stat: -rw-r--r-- 528 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
# I am an Ansible new-style Python module. I leak state from each invocation
# into a class variable and a global variable.

from ansible.module_utils.basic import AnsibleModule


leak1 = []


class MyClass:
    leak2 = []


def main():
    module = AnsibleModule(argument_spec={'name': {'type': 'str'}})
    leak1.append(module.params['name'])
    MyClass.leak2.append(module.params['name'])
    module.exit_json(
        leak1=leak1,
        leak2=MyClass.leak2,
    )

if __name__ == '__main__':
    main()