REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.12 KB
Close
/proc/self/root/proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/guppy/heapy/test/test_menuleak.py
Text
Base64
from tkinter import * import sys import gc class FixedMenu(Menu): # A fix for the .delete() method in Menu. # To delete commands defined in the menu items deleted. # Also changed the comment: INDEX2 is actually INCLUDED. def delete(self, index1, index2=None): """Delete menu items between INDEX1 and INDEX2 (included).""" print(self._tclCommands) if index2 is None: index2 = index1 # First find out what entries have defined commands. cmds = [] for i in range(self.index(index1), self.index(index2)+1): c = str(self.entrycget(i, 'command')) if c in self._tclCommands: # I don't want to delete the command already, since it # seems mystical to do that while the entry is not yet deleted. cmds.append(c) # Delete the menu entries. self.tk.call(self._w, 'delete', index1, index2) # Now that the menu entries have been deleted, we can delete their commands. for c in cmds: self.deletecommand(c) def test1(M): # Test with a single command gc.collect() root = Tk() button = Menubutton(root, text='Window') menu = M(button) button['menu'] = menu def command(): print('command button pressed') rc = sys.getrefcount(command) menu.add_command(command=command) # or add_radiobutton etc idx = menu.index(END) menu.delete(idx) gc.collect() rc1 = sys.getrefcount(command) print('leak test with class', M, end=' ') if rc1 != rc: print('failed: command is now hold by', rc1, 'references') else: print('succeeded: command is now hold by', rc1, 'references') root.destroy() def test2(M): # Test with 3 commands, especially to see that deleting a range works. gc.collect() root = Tk() button = Menubutton(root, text='Window') menu = M(button) button['menu'] = menu def command0(): print('command 0 button pressed') 'deleting 0 and 1' menu.delete(idx0, idx1) def command1(): print('command 1 button pressed') def command2(): print('command 2 button pressed') print('deleting at END') menu.delete(END) root.quit() rc = [sys.getrefcount(x) for x in (command0, command1, command0)] button.pack() # or add_radiobutton etc menu.add_command(command=command0, label='press first') idx0 = menu.index(END) menu.add_radiobutton(command=command1, label='command1') # to see that delete works even when no command supplied menu.add_command(label='no Command') idx1 = menu.index(END) menu.add_command(command=command2, label='press last') idx2 = menu.index(END) root.mainloop() gc.collect() rc1 = [sys.getrefcount(x) for x in (command0, command1, command0)] print('leak test with class', M, end=' ') if rc1 != rc: print('failed: command is now hold by', rc1, 'references, should be', rc) else: print('succeeded: command is now hold by', rc1, 'references') root.destroy() for M in (Menu, FixedMenu,): test1(M) test2(M)
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 18
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2026-02-06 08:01:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
support.py
3.72 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_all.py
682 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_Classifiers.py
28.38 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_dependencies.py
214 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_ER.py
12.56 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_gsl.py
421 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_heapyc.py
15.60 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_menuleak.py
3.12 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_OutputHandling.py
1.34 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_Part.py
10.15 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_Path.py
28.82 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_RefPat.py
16.75 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_RetaGraph.py
95 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_sf.py
583 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_Spec.py
351 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_UniSet.py
1.21 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_View.py
7.99 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
47 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).