Linux ip-172-26-2-223 5.4.0-1018-aws #18-Ubuntu SMP Wed Jun 24 01:15:00 UTC 2020 x86_64
Apache
: 172.26.2.223 | : 18.222.30.59
Cant Read [ /etc/named.conf ]
8.1.13
www
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
www /
server /
panel /
pyenv /
lib /
python3.12 /
test /
[ HOME SHELL ]
Name
Size
Permission
Action
audiodata
[ DIR ]
drwxr-xr-x
certdata
[ DIR ]
drwxr-xr-x
cjkencodings
[ DIR ]
drwxr-xr-x
configdata
[ DIR ]
drwxr-xr-x
crashers
[ DIR ]
drwxr-xr-x
data
[ DIR ]
drwxr-xr-x
decimaltestdata
[ DIR ]
drwxr-xr-x
dtracedata
[ DIR ]
drwxr-xr-x
encoded_modules
[ DIR ]
drwxr-xr-x
imghdrdata
[ DIR ]
drwxr-xr-x
leakers
[ DIR ]
drwxr-xr-x
libregrtest
[ DIR ]
drwxr-xr-x
regrtestdata
[ DIR ]
drwxr-xr-x
sndhdrdata
[ DIR ]
drwxr-xr-x
subprocessdata
[ DIR ]
drwxr-xr-x
support
[ DIR ]
drwxr-xr-x
test_asyncio
[ DIR ]
drwxr-xr-x
test_capi
[ DIR ]
drwxr-xr-x
test_concurrent_futures
[ DIR ]
drwxr-xr-x
test_cppext
[ DIR ]
drwxr-xr-x
test_ctypes
[ DIR ]
drwxr-xr-x
test_dataclasses
[ DIR ]
drwxr-xr-x
test_doctest
[ DIR ]
drwxr-xr-x
test_email
[ DIR ]
drwxr-xr-x
test_future_stmt
[ DIR ]
drwxr-xr-x
test_gdb
[ DIR ]
drwxr-xr-x
test_import
[ DIR ]
drwxr-xr-x
test_importlib
[ DIR ]
drwxr-xr-x
test_inspect
[ DIR ]
drwxr-xr-x
test_json
[ DIR ]
drwxr-xr-x
test_lib2to3
[ DIR ]
drwxr-xr-x
test_module
[ DIR ]
drwxr-xr-x
test_multiprocessing_fork
[ DIR ]
drwxr-xr-x
test_multiprocessing_forkserve...
[ DIR ]
drwxr-xr-x
test_multiprocessing_spawn
[ DIR ]
drwxr-xr-x
test_peg_generator
[ DIR ]
drwxr-xr-x
test_pydoc
[ DIR ]
drwxr-xr-x
test_sqlite3
[ DIR ]
drwxr-xr-x
test_tkinter
[ DIR ]
drwxr-xr-x
test_tomllib
[ DIR ]
drwxr-xr-x
test_tools
[ DIR ]
drwxr-xr-x
test_ttk
[ DIR ]
drwxr-xr-x
test_unittest
[ DIR ]
drwxr-xr-x
test_warnings
[ DIR ]
drwxr-xr-x
test_zipfile
[ DIR ]
drwxr-xr-x
test_zoneinfo
[ DIR ]
drwxr-xr-x
tokenizedata
[ DIR ]
drwxr-xr-x
tracedmodules
[ DIR ]
drwxr-xr-x
typinganndata
[ DIR ]
drwxr-xr-x
wheeldata
[ DIR ]
drwxr-xr-x
xmltestdata
[ DIR ]
drwxr-xr-x
ziptestdata
[ DIR ]
drwxr-xr-x
Sine-1000Hz-300ms.aif
60.25
KB
-rw-r--r--
__init__.py
47
B
-rw-r--r--
__main__.py
67
B
-rw-r--r--
_test_atexit.py
3.61
KB
-rw-r--r--
_test_eintr.py
17.75
KB
-rw-r--r--
_test_embed_set_config.py
8.64
KB
-rw-r--r--
_test_embed_structseq.py
1.99
KB
-rw-r--r--
_test_multiprocessing.py
206.66
KB
-rw-r--r--
_test_venv_multiprocessing.py
796
B
-rw-r--r--
archiver_tests.py
6.1
KB
-rw-r--r--
audiotest.au
27.48
KB
-rw-r--r--
audiotests.py
12.13
KB
-rw-r--r--
audit-tests.py
13.19
KB
-rw-r--r--
autotest.py
214
B
-rw-r--r--
badsyntax_pep3120.py
14
B
-rw-r--r--
bisect_cmd.py
5.34
KB
-rwxr-xr-x
clinic.test.c
138.59
KB
-rw-r--r--
cmath_testcases.txt
141.2
KB
-rw-r--r--
curses_tests.py
1.21
KB
-rwxr-xr-x
datetimetester.py
260.28
KB
-rw-r--r--
dis_module.py
76
B
-rw-r--r--
empty.vbs
70
B
-rw-r--r--
exception_hierarchy.txt
2.33
KB
-rw-r--r--
floating_points.txt
15.92
KB
-rw-r--r--
fork_wait.py
2.29
KB
-rw-r--r--
formatfloat_testcases.txt
7.45
KB
-rw-r--r--
ieee754.txt
3.15
KB
-rw-r--r--
levenshtein_examples.json
406.44
KB
-rw-r--r--
list_tests.py
16.64
KB
-rw-r--r--
lock_tests.py
35.48
KB
-rw-r--r--
mailcap.txt
1.24
KB
-rw-r--r--
mapping_tests.py
21.87
KB
-rw-r--r--
math_testcases.txt
23.19
KB
-rw-r--r--
memory_watchdog.py
711
B
-rw-r--r--
mime.types
47.37
KB
-rw-r--r--
mock_socket.py
3.69
KB
-rw-r--r--
mp_fork_bomb.py
448
B
-rw-r--r--
mp_preload.py
351
B
-rw-r--r--
multibytecodec_support.py
14.19
KB
-rw-r--r--
pickletester.py
143.84
KB
-rw-r--r--
profilee.py
2.97
KB
-rw-r--r--
pstats.pck
65.05
KB
-rw-r--r--
pyclbr_input.py
648
B
-rw-r--r--
pythoninfo.py
28.32
KB
-rw-r--r--
randv2_32.pck
7.34
KB
-rw-r--r--
randv2_64.pck
7.19
KB
-rw-r--r--
randv3.pck
7.82
KB
-rw-r--r--
re_tests.py
25.93
KB
-rwxr-xr-x
recursion.tar
516
B
-rw-r--r--
regrtest.py
1.27
KB
-rwxr-xr-x
relimport.py
27
B
-rw-r--r--
reperf.py
538
B
-rw-r--r--
seq_tests.py
14.96
KB
-rw-r--r--
signalinterproctester.py
3.12
KB
-rw-r--r--
ssl_servers.py
7.12
KB
-rw-r--r--
ssltests.py
1.03
KB
-rw-r--r--
string_tests.py
71.24
KB
-rw-r--r--
test___all__.py
5.04
KB
-rw-r--r--
test__locale.py
8.09
KB
-rw-r--r--
test__opcode.py
4.14
KB
-rw-r--r--
test__osx_support.py
13.62
KB
-rw-r--r--
test__xxinterpchannels.py
52.19
KB
-rw-r--r--
test__xxsubinterpreters.py
27.5
KB
-rw-r--r--
test_abc.py
23.81
KB
-rw-r--r--
test_abstract_numbers.py
5.81
KB
-rw-r--r--
test_aifc.py
17.84
KB
-rw-r--r--
test_argparse.py
189
KB
-rw-r--r--
test_array.py
55.27
KB
-rwxr-xr-x
test_asdl_parser.py
4.44
KB
-rw-r--r--
test_ast.py
140.71
KB
-rw-r--r--
test_asyncgen.py
47.39
KB
-rw-r--r--
test_atexit.py
3.2
KB
-rw-r--r--
test_audioop.py
28.32
KB
-rw-r--r--
test_audit.py
8.6
KB
-rw-r--r--
test_augassign.py
7.68
KB
-rw-r--r--
test_base64.py
35.05
KB
-rw-r--r--
test_baseexception.py
7.77
KB
-rw-r--r--
test_bdb.py
43.75
KB
-rw-r--r--
test_bigaddrspace.py
2.83
KB
-rw-r--r--
test_bigmem.py
45.01
KB
-rw-r--r--
test_binascii.py
19.35
KB
-rw-r--r--
test_binop.py
14.14
KB
-rw-r--r--
test_bisect.py
16.63
KB
-rw-r--r--
test_bool.py
14.25
KB
-rw-r--r--
test_buffer.py
171.31
KB
-rw-r--r--
test_bufio.py
2.56
KB
-rw-r--r--
test_builtin.py
95.14
KB
-rw-r--r--
test_bytes.py
80.57
KB
-rw-r--r--
test_bz2.py
42.61
KB
-rw-r--r--
test_c_locale_coercion.py
20.99
KB
-rw-r--r--
test_calendar.py
51.25
KB
-rw-r--r--
test_call.py
35.21
KB
-rw-r--r--
test_cgi.py
22.27
KB
-rw-r--r--
test_cgitb.py
2.62
KB
-rw-r--r--
test_charmapcodec.py
1.77
KB
-rw-r--r--
test_class.py
19.77
KB
-rw-r--r--
test_clinic.py
83.96
KB
-rw-r--r--
test_cmath.py
23.55
KB
-rw-r--r--
test_cmd.py
6.49
KB
-rw-r--r--
test_cmd_line.py
39.51
KB
-rw-r--r--
test_cmd_line_script.py
34.93
KB
-rw-r--r--
test_code.py
25.7
KB
-rw-r--r--
test_code_module.py
5.53
KB
-rw-r--r--
test_codeccallbacks.py
47.43
KB
-rw-r--r--
test_codecencodings_cn.py
3.86
KB
-rw-r--r--
test_codecencodings_hk.py
701
B
-rw-r--r--
test_codecencodings_iso2022.py
3.65
KB
-rw-r--r--
test_codecencodings_jp.py
4.79
KB
-rw-r--r--
test_codecencodings_kr.py
2.96
KB
-rw-r--r--
test_codecencodings_tw.py
681
B
-rw-r--r--
test_codecmaps_cn.py
746
B
-rw-r--r--
test_codecmaps_hk.py
386
B
-rw-r--r--
test_codecmaps_jp.py
1.7
KB
-rw-r--r--
test_codecmaps_kr.py
1.16
KB
-rw-r--r--
test_codecmaps_tw.py
705
B
-rw-r--r--
test_codecs.py
136.12
KB
-rw-r--r--
test_codeop.py
8.68
KB
-rw-r--r--
test_collections.py
93.47
KB
-rw-r--r--
test_colorsys.py
4.27
KB
-rw-r--r--
test_compare.py
17.46
KB
-rw-r--r--
test_compile.py
78.68
KB
-rw-r--r--
test_compileall.py
48.27
KB
-rw-r--r--
test_compiler_assemble.py
2.46
KB
-rw-r--r--
test_compiler_codegen.py
1.69
KB
-rw-r--r--
test_complex.py
35.37
KB
-rw-r--r--
test_configparser.py
85.34
KB
-rw-r--r--
test_contains.py
3.35
KB
-rw-r--r--
test_context.py
30.78
KB
-rw-r--r--
test_contextlib.py
43.12
KB
-rw-r--r--
test_contextlib_async.py
23.99
KB
-rw-r--r--
test_copy.py
26.52
KB
-rw-r--r--
test_copyreg.py
4.36
KB
-rw-r--r--
test_coroutines.py
67.47
KB
-rw-r--r--
test_cprofile.py
7.36
KB
-rw-r--r--
test_crashers.py
1.17
KB
-rw-r--r--
test_crypt.py
4.19
KB
-rw-r--r--
test_csv.py
61.27
KB
-rw-r--r--
test_curses.py
49.54
KB
-rw-r--r--
test_datetime.py
2.53
KB
-rw-r--r--
test_dbm.py
6.83
KB
-rw-r--r--
test_dbm_dumb.py
11.08
KB
-rw-r--r--
test_dbm_gnu.py
7.24
KB
-rw-r--r--
test_dbm_ndbm.py
5.91
KB
-rw-r--r--
test_decimal.py
216.13
KB
-rw-r--r--
test_decorators.py
14.63
KB
-rw-r--r--
test_defaultdict.py
6.1
KB
-rw-r--r--
test_deque.py
33.16
KB
-rw-r--r--
test_descr.py
196.13
KB
-rw-r--r--
test_descrtut.py
10.98
KB
-rw-r--r--
test_devpoll.py
4.44
KB
-rw-r--r--
test_dict.py
50.92
KB
-rw-r--r--
test_dict_version.py
6.1
KB
-rw-r--r--
test_dictcomps.py
5.15
KB
-rw-r--r--
test_dictviews.py
14.82
KB
-rw-r--r--
test_difflib.py
21.47
KB
-rw-r--r--
test_difflib_expect.html
100.85
KB
-rw-r--r--
test_dis.py
83
KB
-rw-r--r--
test_docxmlrpc.py
9.1
KB
-rw-r--r--
test_dtrace.py
7.98
KB
-rw-r--r--
test_dynamic.py
6
KB
-rw-r--r--
test_dynamicclassattribute.py
9.57
KB
-rw-r--r--
test_eintr.py
627
B
-rw-r--r--
test_embed.py
69.41
KB
-rw-r--r--
test_ensurepip.py
11.49
KB
-rw-r--r--
test_enum.py
186.78
KB
-rw-r--r--
test_enumerate.py
9.14
KB
-rw-r--r--
test_eof.py
3.1
KB
-rw-r--r--
test_epoll.py
9.4
KB
-rw-r--r--
test_errno.py
1.04
KB
-rw-r--r--
test_except_star.py
38.25
KB
-rw-r--r--
test_exception_group.py
34.03
KB
-rw-r--r--
test_exception_hierarchy.py
7.54
KB
-rw-r--r--
test_exception_variations.py
13.74
KB
-rw-r--r--
test_exceptions.py
76.46
KB
-rw-r--r--
test_extcall.py
14.69
KB
-rw-r--r--
test_faulthandler.py
30.31
KB
-rw-r--r--
test_fcntl.py
7.76
KB
-rw-r--r--
test_file.py
11.78
KB
-rw-r--r--
test_file_eintr.py
10.74
KB
-rw-r--r--
test_filecmp.py
10.33
KB
-rw-r--r--
test_fileinput.py
37.85
KB
-rw-r--r--
test_fileio.py
19.98
KB
-rw-r--r--
test_fileutils.py
951
B
-rw-r--r--
test_finalization.py
14.66
KB
-rw-r--r--
test_float.py
64.76
KB
-rw-r--r--
test_flufl.py
1.53
KB
-rw-r--r--
test_fnmatch.py
10.68
KB
-rw-r--r--
test_fork1.py
3.3
KB
-rw-r--r--
test_format.py
28.44
KB
-rw-r--r--
test_fractions.py
52.53
KB
-rw-r--r--
test_frame.py
14.04
KB
-rw-r--r--
test_frozen.py
2.2
KB
-rw-r--r--
test_fstring.py
64.71
KB
-rw-r--r--
test_ftplib.py
41.94
KB
-rw-r--r--
test_funcattrs.py
15.57
KB
-rw-r--r--
test_functools.py
109.31
KB
-rw-r--r--
test_gc.py
47.71
KB
-rw-r--r--
test_generator_stop.py
943
B
-rw-r--r--
test_generators.py
66.13
KB
-rw-r--r--
test_genericalias.py
17.78
KB
-rw-r--r--
test_genericclass.py
9.44
KB
-rw-r--r--
test_genericpath.py
22.29
KB
-rw-r--r--
test_genexps.py
7.3
KB
-rw-r--r--
test_getopt.py
6.6
KB
-rw-r--r--
test_getpass.py
6.37
KB
-rw-r--r--
test_getpath.py
44.36
KB
-rw-r--r--
test_gettext.py
35.67
KB
-rw-r--r--
test_glob.py
17.19
KB
-rw-r--r--
test_global.py
1.2
KB
-rw-r--r--
test_grammar.py
65.97
KB
-rw-r--r--
test_graphlib.py
8.31
KB
-rw-r--r--
test_grp.py
3.67
KB
-rw-r--r--
test_gzip.py
40.94
KB
-rw-r--r--
test_hash.py
12.11
KB
-rw-r--r--
test_hashlib.py
46.71
KB
-rw-r--r--
test_heapq.py
16.42
KB
-rw-r--r--
test_hmac.py
26.06
KB
-rw-r--r--
test_html.py
4.23
KB
-rw-r--r--
test_htmlparser.py
33.37
KB
-rw-r--r--
test_http_cookiejar.py
81.57
KB
-rw-r--r--
test_http_cookies.py
18.7
KB
-rw-r--r--
test_httplib.py
96.14
KB
-rw-r--r--
test_httpservers.py
56.43
KB
-rw-r--r--
test_idle.py
831
B
-rw-r--r--
test_imaplib.py
41.69
KB
-rw-r--r--
test_imghdr.py
4.81
KB
-rw-r--r--
test_index.py
8.37
KB
-rw-r--r--
test_int.py
33.34
KB
-rw-r--r--
test_int_literal.py
6.89
KB
-rw-r--r--
test_interpreters.py
32.11
KB
-rw-r--r--
test_io.py
182.76
KB
-rw-r--r--
test_ioctl.py
3.24
KB
-rw-r--r--
test_ipaddress.py
119.17
KB
-rw-r--r--
test_isinstance.py
12.95
KB
-rw-r--r--
test_iter.py
36.77
KB
-rw-r--r--
test_iterlen.py
7.1
KB
-rw-r--r--
test_itertools.py
106.61
KB
-rw-r--r--
test_keyword.py
2
KB
-rw-r--r--
test_keywordonlyarg.py
6.89
KB
-rw-r--r--
test_kqueue.py
9.36
KB
-rw-r--r--
test_largefile.py
10.17
KB
-rw-r--r--
test_launcher.py
27.23
KB
-rw-r--r--
test_linecache.py
11.04
KB
-rw-r--r--
test_list.py
8.93
KB
-rw-r--r--
test_listcomps.py
20.71
KB
-rw-r--r--
test_lltrace.py
3.71
KB
-rw-r--r--
test_locale.py
24.43
KB
-rw-r--r--
test_logging.py
241.62
KB
-rw-r--r--
test_long.py
63.33
KB
-rw-r--r--
test_longexp.py
233
B
-rw-r--r--
test_lzma.py
92.65
KB
-rw-r--r--
test_mailbox.py
93.91
KB
-rw-r--r--
test_mailcap.py
11.48
KB
-rw-r--r--
test_marshal.py
23.15
KB
-rw-r--r--
test_math.py
107.6
KB
-rw-r--r--
test_math_property.py
1.15
KB
-rw-r--r--
test_memoryio.py
32.65
KB
-rw-r--r--
test_memoryview.py
21.76
KB
-rw-r--r--
test_metaclass.py
6.19
KB
-rw-r--r--
test_mimetypes.py
15.28
KB
-rw-r--r--
test_minidom.py
68.42
KB
-rw-r--r--
test_mmap.py
38.56
KB
-rw-r--r--
test_modulefinder.py
12.21
KB
-rw-r--r--
test_monitoring.py
55.76
KB
-rw-r--r--
test_msilib.py
5.52
KB
-rw-r--r--
test_multibytecodec.py
15.79
KB
-rw-r--r--
test_multiprocessing_main_hand...
11.48
KB
-rw-r--r--
test_named_expressions.py
29.62
KB
-rw-r--r--
test_netrc.py
11.86
KB
-rw-r--r--
test_nis.py
1.25
KB
-rw-r--r--
test_nntplib.py
62.7
KB
-rw-r--r--
test_ntpath.py
52.48
KB
-rw-r--r--
test_numeric_tower.py
8
KB
-rw-r--r--
test_opcache.py
10.89
KB
-rw-r--r--
test_opcodes.py
3.62
KB
-rw-r--r--
test_openpty.py
600
B
-rw-r--r--
test_operator.py
26.72
KB
-rw-r--r--
test_optparse.py
61.02
KB
-rw-r--r--
test_ordered_dict.py
35.62
KB
-rw-r--r--
test_os.py
179.95
KB
-rw-r--r--
test_ossaudiodev.py
7.27
KB
-rw-r--r--
test_osx_env.py
1.31
KB
-rw-r--r--
test_pathlib.py
137.81
KB
-rw-r--r--
test_patma.py
86.03
KB
-rw-r--r--
test_pdb.py
86.53
KB
-rw-r--r--
test_peepholer.py
40.6
KB
-rw-r--r--
test_pep646_syntax.py
7.79
KB
-rw-r--r--
test_perf_profiler.py
11.27
KB
-rw-r--r--
test_perfmaps.py
685
B
-rw-r--r--
test_pickle.py
20.75
KB
-rw-r--r--
test_picklebuffer.py
4.99
KB
-rw-r--r--
test_pickletools.py
4.13
KB
-rw-r--r--
test_pipes.py
6.79
KB
-rw-r--r--
test_pkg.py
9.59
KB
-rw-r--r--
test_pkgutil.py
22.36
KB
-rw-r--r--
test_platform.py
21.59
KB
-rw-r--r--
test_plistlib.py
41.25
KB
-rw-r--r--
test_poll.py
7.39
KB
-rw-r--r--
test_popen.py
2.11
KB
-rw-r--r--
test_poplib.py
17.05
KB
-rw-r--r--
test_positional_only_arg.py
18.44
KB
-rw-r--r--
test_posix.py
95.07
KB
-rw-r--r--
test_posixpath.py
33.75
KB
-rw-r--r--
test_pow.py
6.38
KB
-rw-r--r--
test_pprint.py
50.59
KB
-rw-r--r--
test_print.py
7.72
KB
-rw-r--r--
test_profile.py
8.69
KB
-rw-r--r--
test_property.py
18.03
KB
-rw-r--r--
test_pstats.py
4.31
KB
-rw-r--r--
test_pty.py
16.18
KB
-rw-r--r--
test_pulldom.py
12.33
KB
-rw-r--r--
test_pwd.py
4.32
KB
-rw-r--r--
test_py_compile.py
11.93
KB
-rw-r--r--
test_pyclbr.py
10.15
KB
-rw-r--r--
test_pyexpat.py
29.35
KB
-rw-r--r--
test_queue.py
20.61
KB
-rw-r--r--
test_quopri.py
7.87
KB
-rw-r--r--
test_raise.py
13.44
KB
-rw-r--r--
test_random.py
56.69
KB
-rw-r--r--
test_range.py
26.53
KB
-rw-r--r--
test_re.py
131.37
KB
-rw-r--r--
test_readline.py
12.76
KB
-rw-r--r--
test_regrtest.py
90.02
KB
-rw-r--r--
test_repl.py
4.99
KB
-rw-r--r--
test_reprlib.py
27.77
KB
-rw-r--r--
test_resource.py
7.12
KB
-rw-r--r--
test_richcmp.py
11.95
KB
-rw-r--r--
test_rlcompleter.py
7.4
KB
-rw-r--r--
test_robotparser.py
11.02
KB
-rw-r--r--
test_runpy.py
33.95
KB
-rw-r--r--
test_sax.py
54.63
KB
-rw-r--r--
test_sched.py
7.38
KB
-rw-r--r--
test_scope.py
21.21
KB
-rw-r--r--
test_script_helper.py
5.82
KB
-rw-r--r--
test_secrets.py
4.28
KB
-rw-r--r--
test_select.py
3.42
KB
-rw-r--r--
test_selectors.py
19.64
KB
-rw-r--r--
test_set.py
71.31
KB
-rw-r--r--
test_setcomps.py
3.8
KB
-rw-r--r--
test_shelve.py
6.42
KB
-rw-r--r--
test_shlex.py
13.39
KB
-rw-r--r--
test_shutil.py
126.96
KB
-rw-r--r--
test_signal.py
52.42
KB
-rw-r--r--
test_site.py
29.79
KB
-rw-r--r--
test_slice.py
9.46
KB
-rw-r--r--
test_smtplib.py
60.02
KB
-rw-r--r--
test_smtpnet.py
3.03
KB
-rw-r--r--
test_sndhdr.py
1.51
KB
-rw-r--r--
test_socket.py
254.72
KB
-rw-r--r--
test_socketserver.py
17.39
KB
-rw-r--r--
test_sort.py
13.59
KB
-rw-r--r--
test_source_encoding.py
12.65
KB
-rw-r--r--
test_spwd.py
2.83
KB
-rw-r--r--
test_ssl.py
215.24
KB
-rw-r--r--
test_stable_abi_ctypes.py
24.75
KB
-rw-r--r--
test_startfile.py
1.7
KB
-rw-r--r--
test_stat.py
8.92
KB
-rw-r--r--
test_statistics.py
120.02
KB
-rw-r--r--
test_strftime.py
7.4
KB
-rw-r--r--
test_string.py
21.86
KB
-rw-r--r--
test_string_literals.py
13.07
KB
-rw-r--r--
test_stringprep.py
3.04
KB
-rw-r--r--
test_strptime.py
36.48
KB
-rw-r--r--
test_strtod.py
20.06
KB
-rw-r--r--
test_struct.py
38.45
KB
-rw-r--r--
test_structseq.py
7.23
KB
-rw-r--r--
test_subclassinit.py
8.04
KB
-rw-r--r--
test_subprocess.py
162.29
KB
-rw-r--r--
test_sunau.py
6.09
KB
-rw-r--r--
test_sundry.py
1.02
KB
-rw-r--r--
test_super.py
13.9
KB
-rw-r--r--
test_support.py
27.05
KB
-rw-r--r--
test_symtable.py
11.05
KB
-rw-r--r--
test_syntax.py
71.87
KB
-rw-r--r--
test_sys.py
65.64
KB
-rw-r--r--
test_sys_setprofile.py
13.71
KB
-rw-r--r--
test_sys_settrace.py
84.56
KB
-rw-r--r--
test_sysconfig.py
22.45
KB
-rw-r--r--
test_syslog.py
4.7
KB
-rw-r--r--
test_tabnanny.py
13.89
KB
-rw-r--r--
test_tarfile.py
159.67
KB
-rw-r--r--
test_tcl.py
27.22
KB
-rw-r--r--
test_telnetlib.py
12.85
KB
-rw-r--r--
test_tempfile.py
73.86
KB
-rw-r--r--
test_termios.py
10.95
KB
-rw-r--r--
test_textwrap.py
41.89
KB
-rw-r--r--
test_thread.py
8.87
KB
-rw-r--r--
test_threadedtempfile.py
1.93
KB
-rw-r--r--
test_threading.py
73
KB
-rw-r--r--
test_threading_local.py
6.58
KB
-rw-r--r--
test_threadsignals.py
9.87
KB
-rw-r--r--
test_time.py
42.44
KB
-rw-r--r--
test_timeit.py
15.2
KB
-rw-r--r--
test_timeout.py
10.74
KB
-rw-r--r--
test_tix.py
1.05
KB
-rw-r--r--
test_tokenize.py
115.33
KB
-rw-r--r--
test_trace.py
20.58
KB
-rw-r--r--
test_traceback.py
142.96
KB
-rw-r--r--
test_tracemalloc.py
39.54
KB
-rw-r--r--
test_ttk_textonly.py
16.69
KB
-rw-r--r--
test_tty.py
3.63
KB
-rw-r--r--
test_tuple.py
19.8
KB
-rw-r--r--
test_turtle.py
14.04
KB
-rw-r--r--
test_type_aliases.py
11.65
KB
-rw-r--r--
test_type_annotations.py
6.23
KB
-rw-r--r--
test_type_cache.py
6.6
KB
-rw-r--r--
test_type_comments.py
10.5
KB
-rw-r--r--
test_type_params.py
34.24
KB
-rw-r--r--
test_typechecks.py
2.55
KB
-rw-r--r--
test_types.py
80.76
KB
-rw-r--r--
test_typing.py
334.07
KB
-rw-r--r--
test_ucn.py
9.52
KB
-rw-r--r--
test_unary.py
1.52
KB
-rw-r--r--
test_unicode.py
124.82
KB
-rw-r--r--
test_unicode_file.py
5.72
KB
-rw-r--r--
test_unicode_file_functions.py
6.91
KB
-rw-r--r--
test_unicode_identifiers.py
997
B
-rw-r--r--
test_unicodedata.py
17.01
KB
-rw-r--r--
test_univnewlines.py
3.85
KB
-rw-r--r--
test_unpack.py
3.51
KB
-rw-r--r--
test_unpack_ex.py
9.89
KB
-rw-r--r--
test_unparse.py
27.75
KB
-rw-r--r--
test_urllib.py
70.17
KB
-rw-r--r--
test_urllib2.py
80.73
KB
-rw-r--r--
test_urllib2_localnet.py
25.59
KB
-rw-r--r--
test_urllib2net.py
13.96
KB
-rw-r--r--
test_urllib_response.py
2
KB
-rw-r--r--
test_urllibnet.py
9.41
KB
-rw-r--r--
test_urlparse.py
73.73
KB
-rw-r--r--
test_userdict.py
7.56
KB
-rw-r--r--
test_userlist.py
1.97
KB
-rw-r--r--
test_userstring.py
2.52
KB
-rw-r--r--
test_utf8_mode.py
10.31
KB
-rw-r--r--
test_utf8source.py
1.15
KB
-rw-r--r--
test_uu.py
9.2
KB
-rw-r--r--
test_uuid.py
44.26
KB
-rwxr-xr-x
test_venv.py
32.42
KB
-rw-r--r--
test_wait3.py
1.74
KB
-rw-r--r--
test_wait4.py
1.14
KB
-rw-r--r--
test_wave.py
7.64
KB
-rw-r--r--
test_weakref.py
74.32
KB
-rw-r--r--
test_weakset.py
16.3
KB
-rw-r--r--
test_webbrowser.py
10.5
KB
-rw-r--r--
test_winconsoleio.py
6.69
KB
-rw-r--r--
test_winreg.py
22.48
KB
-rw-r--r--
test_winsound.py
5.32
KB
-rw-r--r--
test_with.py
26.02
KB
-rw-r--r--
test_wmi.py
2.89
KB
-rw-r--r--
test_wsgiref.py
29.32
KB
-rw-r--r--
test_xdrlib.py
2.25
KB
-rw-r--r--
test_xml_dom_minicompat.py
4.18
KB
-rw-r--r--
test_xml_etree.py
160.22
KB
-rw-r--r--
test_xml_etree_c.py
9.34
KB
-rw-r--r--
test_xmlrpc.py
58.08
KB
-rw-r--r--
test_xmlrpc_net.py
954
B
-rw-r--r--
test_xxlimited.py
2.46
KB
-rw-r--r--
test_xxtestfuzz.py
690
B
-rw-r--r--
test_yield_from.py
50.23
KB
-rw-r--r--
test_zipapp.py
16.6
KB
-rw-r--r--
test_zipfile64.py
5.78
KB
-rw-r--r--
test_zipimport.py
32.97
KB
-rw-r--r--
test_zipimport_support.py
10.57
KB
-rw-r--r--
test_zlib.py
41.47
KB
-rw-r--r--
testcodec.py
1.02
KB
-rw-r--r--
testtar.tar
425
KB
-rw-r--r--
testtar.tar.xz
172
B
-rw-r--r--
tf_inherit_check.py
714
B
-rw-r--r--
time_hashlib.py
2.87
KB
-rw-r--r--
win_console_handler.py
1.38
KB
-rw-r--r--
xmltests.py
499
B
-rw-r--r--
zip_cp437_header.zip
270
B
-rw-r--r--
zipdir.zip
374
B
-rw-r--r--
zipdir_backslash.zip
192
B
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : test_peepholer.py
import dis from itertools import combinations, product import sys import textwrap import unittest from test import support from test.support.bytecode_helper import BytecodeTestCase, CfgOptimizationTestCase def compile_pattern_with_fast_locals(pattern): source = textwrap.dedent( f""" def f(x): match x: case {pattern}: pass """ ) namespace = {} exec(source, namespace) return namespace["f"].__code__ def count_instr_recursively(f, opname): count = 0 for instr in dis.get_instructions(f): if instr.opname == opname: count += 1 if hasattr(f, '__code__'): f = f.__code__ for c in f.co_consts: if hasattr(c, 'co_code'): count += count_instr_recursively(c, opname) return count class TestTranforms(BytecodeTestCase): def check_jump_targets(self, code): instructions = list(dis.get_instructions(code)) targets = {instr.offset: instr for instr in instructions} for instr in instructions: if 'JUMP_' not in instr.opname: continue tgt = targets[instr.argval] # jump to unconditional jump if tgt.opname in ('JUMP_BACKWARD', 'JUMP_FORWARD'): self.fail(f'{instr.opname} at {instr.offset} ' f'jumps to {tgt.opname} at {tgt.offset}') # unconditional jump to RETURN_VALUE if (instr.opname in ('JUMP_BACKWARD', 'JUMP_FORWARD') and tgt.opname == 'RETURN_VALUE'): self.fail(f'{instr.opname} at {instr.offset} ' f'jumps to {tgt.opname} at {tgt.offset}') def check_lnotab(self, code): "Check that the lnotab byte offsets are sensible." code = dis._get_code_object(code) lnotab = list(dis.findlinestarts(code)) # Don't bother checking if the line info is sensible, because # most of the line info we can get at comes from lnotab. min_bytecode = min(t[0] for t in lnotab) max_bytecode = max(t[0] for t in lnotab) self.assertGreaterEqual(min_bytecode, 0) self.assertLess(max_bytecode, len(code.co_code)) # This could conceivably test more (and probably should, as there # aren't very many tests of lnotab), if peepholer wasn't scheduled # to be replaced anyway. def test_unot(self): # UNARY_NOT POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE' def unot(x): if not x == 2: del x self.assertNotInBytecode(unot, 'UNARY_NOT') self.assertNotInBytecode(unot, 'POP_JUMP_IF_FALSE') self.assertInBytecode(unot, 'POP_JUMP_IF_TRUE') self.check_lnotab(unot) def test_elim_inversion_of_is_or_in(self): for line, cmp_op, invert in ( ('not a is b', 'IS_OP', 1,), ('not a is not b', 'IS_OP', 0,), ('not a in b', 'CONTAINS_OP', 1,), ('not a not in b', 'CONTAINS_OP', 0,), ): with self.subTest(line=line): code = compile(line, '', 'single') self.assertInBytecode(code, cmp_op, invert) self.check_lnotab(code) def test_global_as_constant(self): # LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False def f(): x = None x = None return x def g(): x = True return x def h(): x = False return x for func, elem in ((f, None), (g, True), (h, False)): with self.subTest(func=func): self.assertNotInBytecode(func, 'LOAD_GLOBAL') self.assertInBytecode(func, 'LOAD_CONST', elem) self.check_lnotab(func) def f(): 'Adding a docstring made this test fail in Py2.5.0' return None self.assertNotInBytecode(f, 'LOAD_GLOBAL') self.assertInBytecode(f, 'RETURN_CONST', None) self.check_lnotab(f) def test_while_one(self): # Skip over: LOAD_CONST trueconst POP_JUMP_IF_FALSE xx def f(): while 1: pass return list for elem in ('LOAD_CONST', 'POP_JUMP_IF_FALSE'): self.assertNotInBytecode(f, elem) for elem in ('JUMP_BACKWARD',): self.assertInBytecode(f, elem) self.check_lnotab(f) def test_pack_unpack(self): for line, elem in ( ('a, = a,', 'RETURN_CONST',), ('a, b = a, b', 'SWAP',), ('a, b, c = a, b, c', 'SWAP',), ): with self.subTest(line=line): code = compile(line,'','single') self.assertInBytecode(code, elem) self.assertNotInBytecode(code, 'BUILD_TUPLE') self.assertNotInBytecode(code, 'UNPACK_SEQUENCE') self.check_lnotab(code) def test_folding_of_tuples_of_constants(self): for line, elem in ( ('a = 1,2,3', (1, 2, 3)), ('("a","b","c")', ('a', 'b', 'c')), ('a,b,c = 1,2,3', (1, 2, 3)), ('(None, 1, None)', (None, 1, None)), ('((1, 2), 3, 4)', ((1, 2), 3, 4)), ): with self.subTest(line=line): code = compile(line,'','single') self.assertInBytecode(code, 'LOAD_CONST', elem) self.assertNotInBytecode(code, 'BUILD_TUPLE') self.check_lnotab(code) # Long tuples should be folded too. code = compile(repr(tuple(range(10000))),'','single') self.assertNotInBytecode(code, 'BUILD_TUPLE') # One LOAD_CONST for the tuple, one for the None return value load_consts = [instr for instr in dis.get_instructions(code) if instr.opname == 'LOAD_CONST'] self.assertEqual(len(load_consts), 1) self.check_lnotab(code) # Bug 1053819: Tuple of constants misidentified when presented with: # . . . opcode_with_arg 100 unary_opcode BUILD_TUPLE 1 . . . # The following would segfault upon compilation def crater(): (~[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ],) self.check_lnotab(crater) def test_folding_of_lists_of_constants(self): for line, elem in ( # in/not in constants with BUILD_LIST should be folded to a tuple: ('a in [1,2,3]', (1, 2, 3)), ('a not in ["a","b","c"]', ('a', 'b', 'c')), ('a in [None, 1, None]', (None, 1, None)), ('a not in [(1, 2), 3, 4]', ((1, 2), 3, 4)), ): with self.subTest(line=line): code = compile(line, '', 'single') self.assertInBytecode(code, 'LOAD_CONST', elem) self.assertNotInBytecode(code, 'BUILD_LIST') self.check_lnotab(code) def test_folding_of_sets_of_constants(self): for line, elem in ( # in/not in constants with BUILD_SET should be folded to a frozenset: ('a in {1,2,3}', frozenset({1, 2, 3})), ('a not in {"a","b","c"}', frozenset({'a', 'c', 'b'})), ('a in {None, 1, None}', frozenset({1, None})), ('a not in {(1, 2), 3, 4}', frozenset({(1, 2), 3, 4})), ('a in {1, 2, 3, 3, 2, 1}', frozenset({1, 2, 3})), ): with self.subTest(line=line): code = compile(line, '', 'single') self.assertNotInBytecode(code, 'BUILD_SET') self.assertInBytecode(code, 'LOAD_CONST', elem) self.check_lnotab(code) # Ensure that the resulting code actually works: def f(a): return a in {1, 2, 3} def g(a): return a not in {1, 2, 3} self.assertTrue(f(3)) self.assertTrue(not f(4)) self.check_lnotab(f) self.assertTrue(not g(3)) self.assertTrue(g(4)) self.check_lnotab(g) def test_folding_of_binops_on_constants(self): for line, elem in ( ('a = 2+3+4', 9), # chained fold ('"@"*4', '@@@@'), # check string ops ('a="abc" + "def"', 'abcdef'), # check string ops ('a = 3**4', 81), # binary power ('a = 3*4', 12), # binary multiply ('a = 13//4', 3), # binary floor divide ('a = 14%4', 2), # binary modulo ('a = 2+3', 5), # binary add ('a = 13-4', 9), # binary subtract ('a = (12,13)[1]', 13), # binary subscr ('a = 13 << 2', 52), # binary lshift ('a = 13 >> 2', 3), # binary rshift ('a = 13 & 7', 5), # binary and ('a = 13 ^ 7', 10), # binary xor ('a = 13 | 7', 15), # binary or ): with self.subTest(line=line): code = compile(line, '', 'single') self.assertInBytecode(code, 'LOAD_CONST', elem) for instr in dis.get_instructions(code): self.assertFalse(instr.opname.startswith('BINARY_')) self.check_lnotab(code) # Verify that unfoldables are skipped code = compile('a=2+"b"', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', 2) self.assertInBytecode(code, 'LOAD_CONST', 'b') self.check_lnotab(code) # Verify that large sequences do not result from folding code = compile('a="x"*10000', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', 10000) self.assertNotIn("x"*10000, code.co_consts) self.check_lnotab(code) code = compile('a=1<<1000', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', 1000) self.assertNotIn(1<<1000, code.co_consts) self.check_lnotab(code) code = compile('a=2**1000', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', 1000) self.assertNotIn(2**1000, code.co_consts) self.check_lnotab(code) def test_binary_subscr_on_unicode(self): # valid code get optimized code = compile('"foo"[0]', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', 'f') self.assertNotInBytecode(code, 'BINARY_SUBSCR') self.check_lnotab(code) code = compile('"\u0061\uffff"[1]', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', '\uffff') self.assertNotInBytecode(code,'BINARY_SUBSCR') self.check_lnotab(code) # With PEP 393, non-BMP char get optimized code = compile('"\U00012345"[0]', '', 'single') self.assertInBytecode(code, 'LOAD_CONST', '\U00012345') self.assertNotInBytecode(code, 'BINARY_SUBSCR') self.check_lnotab(code) # invalid code doesn't get optimized # out of range code = compile('"fuu"[10]', '', 'single') self.assertInBytecode(code, 'BINARY_SUBSCR') self.check_lnotab(code) def test_folding_of_unaryops_on_constants(self): for line, elem in ( ('-0.5', -0.5), # unary negative ('-0.0', -0.0), # -0.0 ('-(1.0-1.0)', -0.0), # -0.0 after folding ('-0', 0), # -0 ('~-2', 1), # unary invert ('+1', 1), # unary positive ): with self.subTest(line=line): code = compile(line, '', 'single') self.assertInBytecode(code, 'LOAD_CONST', elem) for instr in dis.get_instructions(code): self.assertFalse(instr.opname.startswith('UNARY_')) self.check_lnotab(code) # Check that -0.0 works after marshaling def negzero(): return -(1.0-1.0) for instr in dis.get_instructions(negzero): self.assertFalse(instr.opname.startswith('UNARY_')) self.check_lnotab(negzero) # Verify that unfoldables are skipped for line, elem, opname in ( ('-"abc"', 'abc', 'UNARY_NEGATIVE'), ('~"abc"', 'abc', 'UNARY_INVERT'), ): with self.subTest(line=line): code = compile(line, '', 'single') self.assertInBytecode(code, 'LOAD_CONST', elem) self.assertInBytecode(code, opname) self.check_lnotab(code) def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): return x self.assertNotInBytecode(f, 'LOAD_CONST', None) returns = [instr for instr in dis.get_instructions(f) if instr.opname == 'RETURN_VALUE'] self.assertEqual(len(returns), 1) self.check_lnotab(f) def test_elim_jump_to_return(self): # JUMP_FORWARD to RETURN --> RETURN def f(cond, true_value, false_value): # Intentionally use two-line expression to test issue37213. return (true_value if cond else false_value) self.check_jump_targets(f) self.assertNotInBytecode(f, 'JUMP_FORWARD') self.assertNotInBytecode(f, 'JUMP_BACKWARD') returns = [instr for instr in dis.get_instructions(f) if instr.opname == 'RETURN_VALUE'] self.assertEqual(len(returns), 2) self.check_lnotab(f) def test_elim_jump_to_uncond_jump(self): # POP_JUMP_IF_FALSE to JUMP_FORWARD --> POP_JUMP_IF_FALSE to non-jump def f(): if a: # Intentionally use two-line expression to test issue37213. if (c or d): foo() else: baz() self.check_jump_targets(f) self.check_lnotab(f) def test_elim_jump_to_uncond_jump2(self): # POP_JUMP_IF_FALSE to JUMP_BACKWARD --> POP_JUMP_IF_FALSE to non-jump def f(): while a: # Intentionally use two-line expression to test issue37213. if (c or d): a = foo() self.check_jump_targets(f) self.check_lnotab(f) def test_elim_jump_to_uncond_jump3(self): # Intentionally use two-line expressions to test issue37213. # POP_JUMP_IF_FALSE to POP_JUMP_IF_FALSE --> POP_JUMP_IF_FALSE to non-jump def f(a, b, c): return ((a and b) and c) self.check_jump_targets(f) self.check_lnotab(f) self.assertEqual(count_instr_recursively(f, 'POP_JUMP_IF_FALSE'), 2) # POP_JUMP_IF_TRUE to POP_JUMP_IF_TRUE --> POP_JUMP_IF_TRUE to non-jump def f(a, b, c): return ((a or b) or c) self.check_jump_targets(f) self.check_lnotab(f) self.assertEqual(count_instr_recursively(f, 'POP_JUMP_IF_TRUE'), 2) # JUMP_IF_FALSE_OR_POP to JUMP_IF_TRUE_OR_POP --> POP_JUMP_IF_FALSE to non-jump def f(a, b, c): return ((a and b) or c) self.check_jump_targets(f) self.check_lnotab(f) self.assertEqual(count_instr_recursively(f, 'POP_JUMP_IF_FALSE'), 1) self.assertEqual(count_instr_recursively(f, 'POP_JUMP_IF_TRUE'), 1) # POP_JUMP_IF_TRUE to POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE to non-jump def f(a, b, c): return ((a or b) and c) self.check_jump_targets(f) self.check_lnotab(f) self.assertEqual(count_instr_recursively(f, 'POP_JUMP_IF_FALSE'), 1) self.assertEqual(count_instr_recursively(f, 'POP_JUMP_IF_TRUE'), 1) def test_elim_jump_to_uncond_jump4(self): def f(): for i in range(5): if i > 3: print(i) self.check_jump_targets(f) def test_elim_jump_after_return1(self): # Eliminate dead code: jumps immediately after returns can't be reached def f(cond1, cond2): if cond1: return 1 if cond2: return 2 while 1: return 3 while 1: if cond1: return 4 return 5 return 6 self.assertNotInBytecode(f, 'JUMP_FORWARD') self.assertNotInBytecode(f, 'JUMP_BACKWARD') returns = [instr for instr in dis.get_instructions(f) if instr.opname == 'RETURN_VALUE'] self.assertLessEqual(len(returns), 6) self.check_lnotab(f) def test_make_function_doesnt_bail(self): def f(): def g()->1+1: pass return g self.assertNotInBytecode(f, 'BINARY_OP') self.check_lnotab(f) def test_constant_folding(self): # Issue #11244: aggressive constant folding. exprs = [ '3 * -5', '-3 * 5', '2 * (3 * 4)', '(2 * 3) * 4', '(-1, 2, 3)', '(1, -2, 3)', '(1, 2, -3)', '(1, 2, -3) * 6', 'lambda x: x in {(3 * -5) + (-1 - 6), (1, -2, 3) * 2, None}', ] for e in exprs: with self.subTest(e=e): code = compile(e, '', 'single') for instr in dis.get_instructions(code): self.assertFalse(instr.opname.startswith('UNARY_')) self.assertFalse(instr.opname.startswith('BINARY_')) self.assertFalse(instr.opname.startswith('BUILD_')) self.check_lnotab(code) def test_in_literal_list(self): def containtest(): return x in [a, b] self.assertEqual(count_instr_recursively(containtest, 'BUILD_LIST'), 0) self.check_lnotab(containtest) def test_iterate_literal_list(self): def forloop(): for x in [a, b]: pass self.assertEqual(count_instr_recursively(forloop, 'BUILD_LIST'), 0) self.check_lnotab(forloop) def test_condition_with_binop_with_bools(self): def f(): if True or False: return 1 return 0 self.assertEqual(f(), 1) self.check_lnotab(f) def test_if_with_if_expression(self): # Check bpo-37289 def f(x): if (True if x else False): return True return False self.assertTrue(f(True)) self.check_lnotab(f) def test_trailing_nops(self): # Check the lnotab of a function that even after trivial # optimization has trailing nops, which the lnotab adjustment has to # handle properly (bpo-38115). def f(x): while 1: return 3 while 1: return 5 return 6 self.check_lnotab(f) def test_assignment_idiom_in_comprehensions(self): def listcomp(): return [y for x in a for y in [f(x)]] self.assertEqual(count_instr_recursively(listcomp, 'FOR_ITER'), 1) def setcomp(): return {y for x in a for y in [f(x)]} self.assertEqual(count_instr_recursively(setcomp, 'FOR_ITER'), 1) def dictcomp(): return {y: y for x in a for y in [f(x)]} self.assertEqual(count_instr_recursively(dictcomp, 'FOR_ITER'), 1) def genexpr(): return (y for x in a for y in [f(x)]) self.assertEqual(count_instr_recursively(genexpr, 'FOR_ITER'), 1) @support.requires_resource('cpu') def test_format_combinations(self): flags = '-+ #0' testcases = [ *product(('', '1234', 'абвг'), 'sra'), *product((1234, -1234), 'duioxX'), *product((1234.5678901, -1234.5678901), 'duifegFEG'), *product((float('inf'), -float('inf')), 'fegFEG'), ] width_precs = [ *product(('', '1', '30'), ('', '.', '.0', '.2')), ('', '.40'), ('30', '.40'), ] for value, suffix in testcases: for width, prec in width_precs: for r in range(len(flags) + 1): for spec in combinations(flags, r): fmt = '%' + ''.join(spec) + width + prec + suffix with self.subTest(fmt=fmt, value=value): s1 = fmt % value s2 = eval(f'{fmt!r} % (x,)', {'x': value}) self.assertEqual(s2, s1, f'{fmt = }') def test_format_misc(self): def format(fmt, *values): vars = [f'x{i+1}' for i in range(len(values))] if len(vars) == 1: args = '(' + vars[0] + ',)' else: args = '(' + ', '.join(vars) + ')' return eval(f'{fmt!r} % {args}', dict(zip(vars, values))) self.assertEqual(format('string'), 'string') self.assertEqual(format('x = %s!', 1234), 'x = 1234!') self.assertEqual(format('x = %d!', 1234), 'x = 1234!') self.assertEqual(format('x = %x!', 1234), 'x = 4d2!') self.assertEqual(format('x = %f!', 1234), 'x = 1234.000000!') self.assertEqual(format('x = %s!', 1234.5678901), 'x = 1234.5678901!') self.assertEqual(format('x = %f!', 1234.5678901), 'x = 1234.567890!') self.assertEqual(format('x = %d!', 1234.5678901), 'x = 1234!') self.assertEqual(format('x = %s%% %%%%', 1234), 'x = 1234% %%') self.assertEqual(format('x = %s!', '%% %s'), 'x = %% %s!') self.assertEqual(format('x = %s, y = %d', 12, 34), 'x = 12, y = 34') def test_format_errors(self): with self.assertRaisesRegex(TypeError, 'not enough arguments for format string'): eval("'%s' % ()") with self.assertRaisesRegex(TypeError, 'not all arguments converted during string formatting'): eval("'%s' % (x, y)", {'x': 1, 'y': 2}) with self.assertRaisesRegex(ValueError, 'incomplete format'): eval("'%s%' % (x,)", {'x': 1234}) with self.assertRaisesRegex(ValueError, 'incomplete format'): eval("'%s%%%' % (x,)", {'x': 1234}) with self.assertRaisesRegex(TypeError, 'not enough arguments for format string'): eval("'%s%z' % (x,)", {'x': 1234}) with self.assertRaisesRegex(ValueError, 'unsupported format character'): eval("'%s%z' % (x, 5)", {'x': 1234}) with self.assertRaisesRegex(TypeError, 'a real number is required, not str'): eval("'%d' % (x,)", {'x': '1234'}) with self.assertRaisesRegex(TypeError, 'an integer is required, not float'): eval("'%x' % (x,)", {'x': 1234.56}) with self.assertRaisesRegex(TypeError, 'an integer is required, not str'): eval("'%x' % (x,)", {'x': '1234'}) with self.assertRaisesRegex(TypeError, 'must be real number, not str'): eval("'%f' % (x,)", {'x': '1234'}) with self.assertRaisesRegex(TypeError, 'not enough arguments for format string'): eval("'%s, %s' % (x, *y)", {'x': 1, 'y': []}) with self.assertRaisesRegex(TypeError, 'not all arguments converted during string formatting'): eval("'%s, %s' % (x, *y)", {'x': 1, 'y': [2, 3]}) def test_static_swaps_unpack_two(self): def f(a, b): a, b = a, b b, a = a, b self.assertNotInBytecode(f, "SWAP") def test_static_swaps_unpack_three(self): def f(a, b, c): a, b, c = a, b, c a, c, b = a, b, c b, a, c = a, b, c b, c, a = a, b, c c, a, b = a, b, c c, b, a = a, b, c self.assertNotInBytecode(f, "SWAP") def test_static_swaps_match_mapping(self): for a, b, c in product("_a", "_b", "_c"): pattern = f"{{'a': {a}, 'b': {b}, 'c': {c}}}" with self.subTest(pattern): code = compile_pattern_with_fast_locals(pattern) self.assertNotInBytecode(code, "SWAP") def test_static_swaps_match_class(self): forms = [ "C({}, {}, {})", "C({}, {}, c={})", "C({}, b={}, c={})", "C(a={}, b={}, c={})" ] for a, b, c in product("_a", "_b", "_c"): for form in forms: pattern = form.format(a, b, c) with self.subTest(pattern): code = compile_pattern_with_fast_locals(pattern) self.assertNotInBytecode(code, "SWAP") def test_static_swaps_match_sequence(self): swaps = {"*_, b, c", "a, *_, c", "a, b, *_"} forms = ["{}, {}, {}", "{}, {}, *{}", "{}, *{}, {}", "*{}, {}, {}"] for a, b, c in product("_a", "_b", "_c"): for form in forms: pattern = form.format(a, b, c) with self.subTest(pattern): code = compile_pattern_with_fast_locals(pattern) if pattern in swaps: # If this fails... great! Remove this pattern from swaps # to prevent regressing on any improvement: self.assertInBytecode(code, "SWAP") else: self.assertNotInBytecode(code, "SWAP") class TestBuglets(unittest.TestCase): def test_bug_11510(self): # folded constant set optimization was commingled with the tuple # unpacking optimization which would fail if the set had duplicate # elements so that the set length was unexpected def f(): x, y = {1, 1} return x, y with self.assertRaises(ValueError): f() def test_bpo_42057(self): for i in range(10): try: raise Exception except Exception or Exception: pass def test_bpo_45773_pop_jump_if_true(self): compile("while True or spam: pass", "<test>", "exec") def test_bpo_45773_pop_jump_if_false(self): compile("while True or not spam: pass", "<test>", "exec") class TestMarkingVariablesAsUnKnown(BytecodeTestCase): def setUp(self): self.addCleanup(sys.settrace, sys.gettrace()) sys.settrace(None) def test_load_fast_known_simple(self): def f(): x = 1 y = x + x self.assertInBytecode(f, 'LOAD_FAST') def test_load_fast_unknown_simple(self): def f(): if condition(): x = 1 print(x) self.assertInBytecode(f, 'LOAD_FAST_CHECK') self.assertNotInBytecode(f, 'LOAD_FAST') def test_load_fast_unknown_because_del(self): def f(): x = 1 del x print(x) self.assertInBytecode(f, 'LOAD_FAST_CHECK') self.assertNotInBytecode(f, 'LOAD_FAST') def test_load_fast_known_because_parameter(self): def f1(x): print(x) self.assertInBytecode(f1, 'LOAD_FAST') self.assertNotInBytecode(f1, 'LOAD_FAST_CHECK') def f2(*, x): print(x) self.assertInBytecode(f2, 'LOAD_FAST') self.assertNotInBytecode(f2, 'LOAD_FAST_CHECK') def f3(*args): print(args) self.assertInBytecode(f3, 'LOAD_FAST') self.assertNotInBytecode(f3, 'LOAD_FAST_CHECK') def f4(**kwargs): print(kwargs) self.assertInBytecode(f4, 'LOAD_FAST') self.assertNotInBytecode(f4, 'LOAD_FAST_CHECK') def f5(x=0): print(x) self.assertInBytecode(f5, 'LOAD_FAST') self.assertNotInBytecode(f5, 'LOAD_FAST_CHECK') def test_load_fast_known_because_already_loaded(self): def f(): if condition(): x = 1 print(x) print(x) self.assertInBytecode(f, 'LOAD_FAST_CHECK') self.assertInBytecode(f, 'LOAD_FAST') def test_load_fast_known_multiple_branches(self): def f(): if condition(): x = 1 else: x = 2 print(x) self.assertInBytecode(f, 'LOAD_FAST') self.assertNotInBytecode(f, 'LOAD_FAST_CHECK') def test_load_fast_unknown_after_error(self): def f(): try: res = 1 / 0 except ZeroDivisionError: pass return res # LOAD_FAST (known) still occurs in the no-exception branch. # Assert that it doesn't occur in the LOAD_FAST_CHECK branch. self.assertInBytecode(f, 'LOAD_FAST_CHECK') def test_load_fast_unknown_after_error_2(self): def f(): try: 1 / 0 except: print(a, b, c, d, e, f, g) a = b = c = d = e = f = g = 1 self.assertInBytecode(f, 'LOAD_FAST_CHECK') self.assertNotInBytecode(f, 'LOAD_FAST') def test_load_fast_too_many_locals(self): # When there get to be too many locals to analyze completely, # later locals are all converted to LOAD_FAST_CHECK, except # when a store or prior load occurred in the same basicblock. def f(): a00 = a01 = a02 = a03 = a04 = a05 = a06 = a07 = a08 = a09 = 1 a10 = a11 = a12 = a13 = a14 = a15 = a16 = a17 = a18 = a19 = 1 a20 = a21 = a22 = a23 = a24 = a25 = a26 = a27 = a28 = a29 = 1 a30 = a31 = a32 = a33 = a34 = a35 = a36 = a37 = a38 = a39 = 1 a40 = a41 = a42 = a43 = a44 = a45 = a46 = a47 = a48 = a49 = 1 a50 = a51 = a52 = a53 = a54 = a55 = a56 = a57 = a58 = a59 = 1 a60 = a61 = a62 = a63 = a64 = a65 = a66 = a67 = a68 = a69 = 1 a70 = a71 = a72 = a73 = a74 = a75 = a76 = a77 = a78 = a79 = 1 del a72, a73 print(a73) print(a70, a71, a72, a73) while True: print(a00, a01, a62, a63) print(a64, a65, a78, a79) for i in 0, 1, 62, 63: # First 64 locals: analyze completely self.assertInBytecode(f, 'LOAD_FAST', f"a{i:02}") self.assertNotInBytecode(f, 'LOAD_FAST_CHECK', f"a{i:02}") for i in 64, 65, 78, 79: # Locals >=64 not in the same basicblock self.assertInBytecode(f, 'LOAD_FAST_CHECK', f"a{i:02}") self.assertNotInBytecode(f, 'LOAD_FAST', f"a{i:02}") for i in 70, 71: # Locals >=64 in the same basicblock self.assertInBytecode(f, 'LOAD_FAST', f"a{i:02}") self.assertNotInBytecode(f, 'LOAD_FAST_CHECK', f"a{i:02}") # del statements should invalidate within basicblocks. self.assertInBytecode(f, 'LOAD_FAST_CHECK', "a72") self.assertNotInBytecode(f, 'LOAD_FAST', "a72") # previous checked loads within a basicblock enable unchecked loads self.assertInBytecode(f, 'LOAD_FAST_CHECK', "a73") self.assertInBytecode(f, 'LOAD_FAST', "a73") def test_setting_lineno_no_undefined(self): code = textwrap.dedent("""\ def f(): x = y = 2 if not x: return 4 for i in range(55): x + 6 L = 7 L = 8 L = 9 L = 10 """) ns = {} exec(code, ns) f = ns['f'] self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") co_code = f.__code__.co_code def trace(frame, event, arg): if event == 'line' and frame.f_lineno == 9: frame.f_lineno = 3 sys.settrace(None) return None return trace sys.settrace(trace) result = f() self.assertIsNone(result) self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") self.assertEqual(f.__code__.co_code, co_code) def test_setting_lineno_one_undefined(self): code = textwrap.dedent("""\ def f(): x = y = 2 if not x: return 4 for i in range(55): x + 6 del x L = 8 L = 9 L = 10 """) ns = {} exec(code, ns) f = ns['f'] self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") co_code = f.__code__.co_code def trace(frame, event, arg): if event == 'line' and frame.f_lineno == 9: frame.f_lineno = 3 sys.settrace(None) return None return trace e = r"assigning None to 1 unbound local" with self.assertWarnsRegex(RuntimeWarning, e): sys.settrace(trace) result = f() self.assertEqual(result, 4) self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") self.assertEqual(f.__code__.co_code, co_code) def test_setting_lineno_two_undefined(self): code = textwrap.dedent("""\ def f(): x = y = 2 if not x: return 4 for i in range(55): x + 6 del x, y L = 8 L = 9 L = 10 """) ns = {} exec(code, ns) f = ns['f'] self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") co_code = f.__code__.co_code def trace(frame, event, arg): if event == 'line' and frame.f_lineno == 9: frame.f_lineno = 3 sys.settrace(None) return None return trace e = r"assigning None to 2 unbound locals" with self.assertWarnsRegex(RuntimeWarning, e): sys.settrace(trace) result = f() self.assertEqual(result, 4) self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") self.assertEqual(f.__code__.co_code, co_code) def make_function_with_no_checks(self): code = textwrap.dedent("""\ def f(): x = 2 L = 3 L = 4 L = 5 if not L: x + 7 y = 2 """) ns = {} exec(code, ns) f = ns['f'] self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") return f def test_deleting_local_warns_and_assigns_none(self): f = self.make_function_with_no_checks() co_code = f.__code__.co_code def trace(frame, event, arg): if event == 'line' and frame.f_lineno == 4: del frame.f_locals["x"] sys.settrace(None) return None return trace e = r"assigning None to unbound local 'x'" with self.assertWarnsRegex(RuntimeWarning, e): sys.settrace(trace) f() self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") self.assertEqual(f.__code__.co_code, co_code) def test_modifying_local_does_not_add_check(self): f = self.make_function_with_no_checks() def trace(frame, event, arg): if event == 'line' and frame.f_lineno == 4: frame.f_locals["x"] = 42 sys.settrace(None) return None return trace sys.settrace(trace) f() self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") def test_initializing_local_does_not_add_check(self): f = self.make_function_with_no_checks() def trace(frame, event, arg): if event == 'line' and frame.f_lineno == 4: frame.f_locals["y"] = 42 sys.settrace(None) return None return trace sys.settrace(trace) f() self.assertInBytecode(f, "LOAD_FAST") self.assertNotInBytecode(f, "LOAD_FAST_CHECK") class DirectCfgOptimizerTests(CfgOptimizationTestCase): def cfg_optimization_test(self, insts, expected_insts, consts=None, expected_consts=None, nlocals=0): if expected_consts is None: expected_consts = consts opt_insts, opt_consts = self.get_optimized(insts, consts, nlocals) expected_insts = self.normalize_insts(expected_insts) self.assertInstructionsMatch(opt_insts, expected_insts) self.assertEqual(opt_consts, expected_consts) def test_conditional_jump_forward_non_const_condition(self): insts = [ ('LOAD_NAME', 1, 11), ('POP_JUMP_IF_TRUE', lbl := self.Label(), 12), ('LOAD_CONST', 2, 13), lbl, ('LOAD_CONST', 3, 14), ('RETURN_VALUE', 14), ] expected_insts = [ ('LOAD_NAME', 1, 11), ('POP_JUMP_IF_TRUE', lbl := self.Label(), 12), ('LOAD_CONST', 1, 13), lbl, ('RETURN_CONST', 2, 14), ] self.cfg_optimization_test(insts, expected_insts, consts=[0, 1, 2, 3, 4], expected_consts=[0, 2, 3]) def test_conditional_jump_forward_const_condition(self): # The unreachable branch of the jump is removed, the jump # becomes redundant and is replaced by a NOP (for the lineno) insts = [ ('LOAD_CONST', 3, 11), ('POP_JUMP_IF_TRUE', lbl := self.Label(), 12), ('LOAD_CONST', 2, 13), lbl, ('LOAD_CONST', 3, 14), ('RETURN_VALUE', 14), ] expected_insts = [ ('NOP', 11), ('NOP', 12), ('RETURN_CONST', 1, 14), ] self.cfg_optimization_test(insts, expected_insts, consts=[0, 1, 2, 3, 4], expected_consts=[0, 3]) def test_conditional_jump_backward_non_const_condition(self): insts = [ lbl1 := self.Label(), ('LOAD_NAME', 1, 11), ('POP_JUMP_IF_TRUE', lbl1, 12), ('LOAD_NAME', 2, 13), ('RETURN_VALUE', 13), ] expected = [ lbl := self.Label(), ('LOAD_NAME', 1, 11), ('POP_JUMP_IF_TRUE', lbl, 12), ('LOAD_NAME', 2, 13), ('RETURN_VALUE', 13), ] self.cfg_optimization_test(insts, expected, consts=list(range(5))) def test_conditional_jump_backward_const_condition(self): # The unreachable branch of the jump is removed insts = [ lbl1 := self.Label(), ('LOAD_CONST', 3, 11), ('POP_JUMP_IF_TRUE', lbl1, 12), ('LOAD_CONST', 2, 13), ('RETURN_VALUE', 13), ] expected_insts = [ lbl := self.Label(), ('NOP', 11), ('JUMP', lbl, 12), ] self.cfg_optimization_test(insts, expected_insts, consts=list(range(5))) def test_no_unsafe_static_swap(self): # We can't change order of two stores to the same location insts = [ ('LOAD_CONST', 0, 1), ('LOAD_CONST', 1, 2), ('LOAD_CONST', 2, 3), ('SWAP', 3, 4), ('STORE_FAST', 1, 4), ('STORE_FAST', 1, 4), ('POP_TOP', 0, 4), ('RETURN_VALUE', 5) ] self.cfg_optimization_test(insts, insts, consts=list(range(3)), nlocals=1) def test_only_one_push_null_per_load_global(self): # When optimizing func()(), a second pass shouldn't # let the LOAD_GLOBAL absorb another PUSH_NULL. before = [ ('PUSH_NULL', 0, 1), ('PUSH_NULL', 0, 1), ('LOAD_GLOBAL', 0, 1), ('CALL', 0, 1), ('CALL', 0, 1), ('RETURN_VALUE', 0, 1), ] after = [ ('PUSH_NULL', 0, 1), ('LOAD_GLOBAL', 1, 1), ('CALL', 0, 1), ('CALL', 0, 1), ('RETURN_VALUE', 0, 1), ] self.cfg_optimization_test(before, expected_insts=after, consts=[]) self.cfg_optimization_test(after, expected_insts=after, consts=[]) if __name__ == "__main__": unittest.main()
Close