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 | : 3.145.42.128
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_mmap.py
from test.support import ( requires, _2G, _4G, gc_collect, cpython_only, is_emscripten ) from test.support.import_helper import import_module from test.support.os_helper import TESTFN, unlink import unittest import os import re import itertools import random import socket import string import sys import weakref # Skip test if we can't import mmap. mmap = import_module('mmap') PAGESIZE = mmap.PAGESIZE tagname_prefix = f'python_{os.getpid()}_test_mmap' def random_tagname(length=10): suffix = ''.join(random.choices(string.ascii_uppercase, k=length)) return f'{tagname_prefix}_{suffix}' # Python's mmap module dup()s the file descriptor. Emscripten's FS layer # does not materialize file changes through a dupped fd to a new mmap. if is_emscripten: raise unittest.SkipTest("incompatible with Emscripten's mmap emulation.") class MmapTests(unittest.TestCase): def setUp(self): if os.path.exists(TESTFN): os.unlink(TESTFN) def tearDown(self): try: os.unlink(TESTFN) except OSError: pass def test_basic(self): # Test mmap module on Unix systems and Windows # Create a file to be mmap'ed. f = open(TESTFN, 'bw+') try: # Write 2 pages worth of data to the file f.write(b'\0'* PAGESIZE) f.write(b'foo') f.write(b'\0'* (PAGESIZE-3) ) f.flush() m = mmap.mmap(f.fileno(), 2 * PAGESIZE) finally: f.close() # Simple sanity checks tp = str(type(m)) # SF bug 128713: segfaulted on Linux self.assertEqual(m.find(b'foo'), PAGESIZE) self.assertEqual(len(m), 2*PAGESIZE) self.assertEqual(m[0], 0) self.assertEqual(m[0:3], b'\0\0\0') # Shouldn't crash on boundary (Issue #5292) self.assertRaises(IndexError, m.__getitem__, len(m)) self.assertRaises(IndexError, m.__setitem__, len(m), b'\0') # Modify the file's content m[0] = b'3'[0] m[PAGESIZE +3: PAGESIZE +3+3] = b'bar' # Check that the modification worked self.assertEqual(m[0], b'3'[0]) self.assertEqual(m[0:3], b'3\0\0') self.assertEqual(m[PAGESIZE-1 : PAGESIZE + 7], b'\0foobar\0') m.flush() # Test doing a regular expression match in an mmap'ed file match = re.search(b'[A-Za-z]+', m) if match is None: self.fail('regex match on mmap failed!') else: start, end = match.span(0) length = end - start self.assertEqual(start, PAGESIZE) self.assertEqual(end, PAGESIZE + 6) # test seeking around (try to overflow the seek implementation) m.seek(0,0) self.assertEqual(m.tell(), 0) m.seek(42,1) self.assertEqual(m.tell(), 42) m.seek(0,2) self.assertEqual(m.tell(), len(m)) # Try to seek to negative position... self.assertRaises(ValueError, m.seek, -1) # Try to seek beyond end of mmap... self.assertRaises(ValueError, m.seek, 1, 2) # Try to seek to negative position... self.assertRaises(ValueError, m.seek, -len(m)-1, 2) # Try resizing map try: m.resize(512) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite # would then be different across platforms. pass else: # resize() is supported self.assertEqual(len(m), 512) # Check that we can no longer seek beyond the new size. self.assertRaises(ValueError, m.seek, 513, 0) # Check that the underlying file is truncated too # (bug #728515) f = open(TESTFN, 'rb') try: f.seek(0, 2) self.assertEqual(f.tell(), 512) finally: f.close() self.assertEqual(m.size(), 512) m.close() def test_access_parameter(self): # Test for "access" keyword parameter mapsize = 10 with open(TESTFN, "wb") as fp: fp.write(b"a"*mapsize) with open(TESTFN, "rb") as f: m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ) self.assertEqual(m[:], b'a'*mapsize, "Readonly memory map data incorrect.") # Ensuring that readonly mmap can't be slice assigned try: m[:] = b'b'*mapsize except TypeError: pass else: self.fail("Able to write to readonly memory map") # Ensuring that readonly mmap can't be item assigned try: m[0] = b'b' except TypeError: pass else: self.fail("Able to write to readonly memory map") # Ensuring that readonly mmap can't be write() to try: m.seek(0,0) m.write(b'abc') except TypeError: pass else: self.fail("Able to write to readonly memory map") # Ensuring that readonly mmap can't be write_byte() to try: m.seek(0,0) m.write_byte(b'd') except TypeError: pass else: self.fail("Able to write to readonly memory map") # Ensuring that readonly mmap can't be resized try: m.resize(2*mapsize) except SystemError: # resize is not universally supported pass except TypeError: pass else: self.fail("Able to resize readonly memory map") with open(TESTFN, "rb") as fp: self.assertEqual(fp.read(), b'a'*mapsize, "Readonly memory map data file was modified") # Opening mmap with size too big with open(TESTFN, "r+b") as f: try: m = mmap.mmap(f.fileno(), mapsize+1) except ValueError: # we do not expect a ValueError on Windows # CAUTION: This also changes the size of the file on disk, and # later tests assume that the length hasn't changed. We need to # repair that. if sys.platform.startswith('win'): self.fail("Opening mmap with size+1 should work on Windows.") else: # we expect a ValueError on Unix, but not on Windows if not sys.platform.startswith('win'): self.fail("Opening mmap with size+1 should raise ValueError.") m.close() if sys.platform.startswith('win'): # Repair damage from the resizing test. with open(TESTFN, 'r+b') as f: f.truncate(mapsize) # Opening mmap with access=ACCESS_WRITE with open(TESTFN, "r+b") as f: m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE) # Modifying write-through memory map m[:] = b'c'*mapsize self.assertEqual(m[:], b'c'*mapsize, "Write-through memory map memory not updated properly.") m.flush() m.close() with open(TESTFN, 'rb') as f: stuff = f.read() self.assertEqual(stuff, b'c'*mapsize, "Write-through memory map data file not updated properly.") # Opening mmap with access=ACCESS_COPY with open(TESTFN, "r+b") as f: m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY) # Modifying copy-on-write memory map m[:] = b'd'*mapsize self.assertEqual(m[:], b'd' * mapsize, "Copy-on-write memory map data not written correctly.") m.flush() with open(TESTFN, "rb") as fp: self.assertEqual(fp.read(), b'c'*mapsize, "Copy-on-write test data file should not be modified.") # Ensuring copy-on-write maps cannot be resized self.assertRaises(TypeError, m.resize, 2*mapsize) m.close() # Ensuring invalid access parameter raises exception with open(TESTFN, "r+b") as f: self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4) if os.name == "posix": # Try incompatible flags, prot and access parameters. with open(TESTFN, "r+b") as f: self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, flags=mmap.MAP_PRIVATE, prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE) # Try writing with PROT_EXEC and without PROT_WRITE prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0) with open(TESTFN, "r+b") as f: try: m = mmap.mmap(f.fileno(), mapsize, prot=prot) except PermissionError: # on macOS 14, PROT_READ | PROT_EXEC is not allowed pass else: self.assertRaises(TypeError, m.write, b"abcdef") self.assertRaises(TypeError, m.write_byte, 0) m.close() def test_bad_file_desc(self): # Try opening a bad file descriptor... self.assertRaises(OSError, mmap.mmap, -2, 4096) def test_tougher_find(self): # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, # searching for data with embedded \0 bytes didn't work. with open(TESTFN, 'wb+') as f: data = b'aabaac\x00deef\x00\x00aa\x00' n = len(data) f.write(data) f.flush() m = mmap.mmap(f.fileno(), n) for start in range(n+1): for finish in range(start, n+1): slice = data[start : finish] self.assertEqual(m.find(slice), data.find(slice)) self.assertEqual(m.find(slice + b'x'), -1) m.close() def test_find_end(self): # test the new 'end' parameter works as expected with open(TESTFN, 'wb+') as f: data = b'one two ones' n = len(data) f.write(data) f.flush() m = mmap.mmap(f.fileno(), n) self.assertEqual(m.find(b'one'), 0) self.assertEqual(m.find(b'ones'), 8) self.assertEqual(m.find(b'one', 0, -1), 0) self.assertEqual(m.find(b'one', 1), 8) self.assertEqual(m.find(b'one', 1, -1), 8) self.assertEqual(m.find(b'one', 1, -2), -1) self.assertEqual(m.find(bytearray(b'one')), 0) for i in range(-n-1, n+1): for j in range(-n-1, n+1): for p in [b"o", b"on", b"two", b"ones", b"s"]: expected = data.find(p, i, j) self.assertEqual(m.find(p, i, j), expected, (p, i, j)) def test_find_does_not_access_beyond_buffer(self): try: flags = mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS PAGESIZE = mmap.PAGESIZE PROT_NONE = 0 PROT_READ = mmap.PROT_READ except AttributeError as e: raise unittest.SkipTest("mmap flags unavailable") from e for i in range(0, 2049): with mmap.mmap(-1, PAGESIZE * (i + 1), flags=flags, prot=PROT_NONE) as guard: with mmap.mmap(-1, PAGESIZE * (i + 2048), flags=flags, prot=PROT_READ) as fm: fm.find(b"fo", -2) def test_rfind(self): # test the new 'end' parameter works as expected with open(TESTFN, 'wb+') as f: data = b'one two ones' n = len(data) f.write(data) f.flush() m = mmap.mmap(f.fileno(), n) self.assertEqual(m.rfind(b'one'), 8) self.assertEqual(m.rfind(b'one '), 0) self.assertEqual(m.rfind(b'one', 0, -1), 8) self.assertEqual(m.rfind(b'one', 0, -2), 0) self.assertEqual(m.rfind(b'one', 1, -1), 8) self.assertEqual(m.rfind(b'one', 1, -2), -1) self.assertEqual(m.rfind(bytearray(b'one')), 8) def test_double_close(self): # make sure a double close doesn't crash on Solaris (Bug# 665913) with open(TESTFN, 'wb+') as f: f.write(2**16 * b'a') # Arbitrary character with open(TESTFN, 'rb') as f: mf = mmap.mmap(f.fileno(), 2**16, access=mmap.ACCESS_READ) mf.close() mf.close() def test_entire_file(self): # test mapping of entire file by passing 0 for map length with open(TESTFN, "wb+") as f: f.write(2**16 * b'm') # Arbitrary character with open(TESTFN, "rb+") as f, \ mmap.mmap(f.fileno(), 0) as mf: self.assertEqual(len(mf), 2**16, "Map size should equal file size.") self.assertEqual(mf.read(2**16), 2**16 * b"m") def test_length_0_offset(self): # Issue #10916: test mapping of remainder of file by passing 0 for # map length with an offset doesn't cause a segfault. # NOTE: allocation granularity is currently 65536 under Win64, # and therefore the minimum offset alignment. with open(TESTFN, "wb") as f: f.write((65536 * 2) * b'm') # Arbitrary character with open(TESTFN, "rb") as f: with mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ) as mf: self.assertRaises(IndexError, mf.__getitem__, 80000) def test_length_0_large_offset(self): # Issue #10959: test mapping of a file by passing 0 for # map length with a large offset doesn't cause a segfault. with open(TESTFN, "wb") as f: f.write(115699 * b'm') # Arbitrary character with open(TESTFN, "w+b") as f: self.assertRaises(ValueError, mmap.mmap, f.fileno(), 0, offset=2147418112) def test_move(self): # make move works everywhere (64-bit format problem earlier) with open(TESTFN, 'wb+') as f: f.write(b"ABCDEabcde") # Arbitrary character f.flush() mf = mmap.mmap(f.fileno(), 10) mf.move(5, 0, 5) self.assertEqual(mf[:], b"ABCDEABCDE", "Map move should have duplicated front 5") mf.close() # more excessive test data = b"0123456789" for dest in range(len(data)): for src in range(len(data)): for count in range(len(data) - max(dest, src)): expected = data[:dest] + data[src:src+count] + data[dest+count:] m = mmap.mmap(-1, len(data)) m[:] = data m.move(dest, src, count) self.assertEqual(m[:], expected) m.close() # segfault test (Issue 5387) m = mmap.mmap(-1, 100) offsets = [-100, -1, 0, 1, 100] for source, dest, size in itertools.product(offsets, offsets, offsets): try: m.move(source, dest, size) except ValueError: pass offsets = [(-1, -1, -1), (-1, -1, 0), (-1, 0, -1), (0, -1, -1), (-1, 0, 0), (0, -1, 0), (0, 0, -1)] for source, dest, size in offsets: self.assertRaises(ValueError, m.move, source, dest, size) m.close() m = mmap.mmap(-1, 1) # single byte self.assertRaises(ValueError, m.move, 0, 0, 2) self.assertRaises(ValueError, m.move, 1, 0, 1) self.assertRaises(ValueError, m.move, 0, 1, 1) m.move(0, 0, 1) m.move(0, 0, 0) def test_anonymous(self): # anonymous mmap.mmap(-1, PAGE) m = mmap.mmap(-1, PAGESIZE) for x in range(PAGESIZE): self.assertEqual(m[x], 0, "anonymously mmap'ed contents should be zero") for x in range(PAGESIZE): b = x & 0xff m[x] = b self.assertEqual(m[x], b) def test_read_all(self): m = mmap.mmap(-1, 16) self.addCleanup(m.close) # With no parameters, or None or a negative argument, reads all m.write(bytes(range(16))) m.seek(0) self.assertEqual(m.read(), bytes(range(16))) m.seek(8) self.assertEqual(m.read(), bytes(range(8, 16))) m.seek(16) self.assertEqual(m.read(), b'') m.seek(3) self.assertEqual(m.read(None), bytes(range(3, 16))) m.seek(4) self.assertEqual(m.read(-1), bytes(range(4, 16))) m.seek(5) self.assertEqual(m.read(-2), bytes(range(5, 16))) m.seek(9) self.assertEqual(m.read(-42), bytes(range(9, 16))) def test_read_invalid_arg(self): m = mmap.mmap(-1, 16) self.addCleanup(m.close) self.assertRaises(TypeError, m.read, 'foo') self.assertRaises(TypeError, m.read, 5.5) self.assertRaises(TypeError, m.read, [1, 2, 3]) def test_extended_getslice(self): # Test extended slicing by comparing with list slicing. s = bytes(reversed(range(256))) m = mmap.mmap(-1, len(s)) m[:] = s self.assertEqual(m[:], s) indices = (0, None, 1, 3, 19, 300, sys.maxsize, -1, -2, -31, -300) for start in indices: for stop in indices: # Skip step 0 (invalid) for step in indices[1:]: self.assertEqual(m[start:stop:step], s[start:stop:step]) def test_extended_set_del_slice(self): # Test extended slicing by comparing with list slicing. s = bytes(reversed(range(256))) m = mmap.mmap(-1, len(s)) indices = (0, None, 1, 3, 19, 300, sys.maxsize, -1, -2, -31, -300) for start in indices: for stop in indices: # Skip invalid step 0 for step in indices[1:]: m[:] = s self.assertEqual(m[:], s) L = list(s) # Make sure we have a slice of exactly the right length, # but with different data. data = L[start:stop:step] data = bytes(reversed(data)) L[start:stop:step] = data m[start:stop:step] = data self.assertEqual(m[:], bytes(L)) def make_mmap_file (self, f, halfsize): # Write 2 pages worth of data to the file f.write (b'\0' * halfsize) f.write (b'foo') f.write (b'\0' * (halfsize - 3)) f.flush () return mmap.mmap (f.fileno(), 0) def test_empty_file (self): f = open (TESTFN, 'w+b') f.close() with open(TESTFN, "rb") as f : self.assertRaisesRegex(ValueError, "cannot mmap an empty file", mmap.mmap, f.fileno(), 0, access=mmap.ACCESS_READ) def test_offset (self): f = open (TESTFN, 'w+b') try: # unlink TESTFN no matter what halfsize = mmap.ALLOCATIONGRANULARITY m = self.make_mmap_file (f, halfsize) m.close () f.close () mapsize = halfsize * 2 # Try invalid offset f = open(TESTFN, "r+b") for offset in [-2, -1, None]: try: m = mmap.mmap(f.fileno(), mapsize, offset=offset) self.assertEqual(0, 1) except (ValueError, TypeError, OverflowError): pass else: self.assertEqual(0, 0) f.close() # Try valid offset, hopefully 8192 works on all OSes f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize) self.assertEqual(m[0:3], b'foo') f.close() # Try resizing map try: m.resize(512) except SystemError: pass else: # resize() is supported self.assertEqual(len(m), 512) # Check that we can no longer seek beyond the new size. self.assertRaises(ValueError, m.seek, 513, 0) # Check that the content is not changed self.assertEqual(m[0:3], b'foo') # Check that the underlying file is truncated too f = open(TESTFN, 'rb') f.seek(0, 2) self.assertEqual(f.tell(), halfsize + 512) f.close() self.assertEqual(m.size(), halfsize + 512) m.close() finally: f.close() try: os.unlink(TESTFN) except OSError: pass def test_subclass(self): class anon_mmap(mmap.mmap): def __new__(klass, *args, **kwargs): return mmap.mmap.__new__(klass, -1, *args, **kwargs) anon_mmap(PAGESIZE) @unittest.skipUnless(hasattr(mmap, 'PROT_READ'), "needs mmap.PROT_READ") def test_prot_readonly(self): mapsize = 10 with open(TESTFN, "wb") as fp: fp.write(b"a"*mapsize) with open(TESTFN, "rb") as f: m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ) self.assertRaises(TypeError, m.write, "foo") def test_error(self): self.assertIs(mmap.error, OSError) def test_io_methods(self): data = b"0123456789" with open(TESTFN, "wb") as fp: fp.write(b"x"*len(data)) with open(TESTFN, "r+b") as f: m = mmap.mmap(f.fileno(), len(data)) # Test write_byte() for i in range(len(data)): self.assertEqual(m.tell(), i) m.write_byte(data[i]) self.assertEqual(m.tell(), i+1) self.assertRaises(ValueError, m.write_byte, b"x"[0]) self.assertEqual(m[:], data) # Test read_byte() m.seek(0) for i in range(len(data)): self.assertEqual(m.tell(), i) self.assertEqual(m.read_byte(), data[i]) self.assertEqual(m.tell(), i+1) self.assertRaises(ValueError, m.read_byte) # Test read() m.seek(3) self.assertEqual(m.read(3), b"345") self.assertEqual(m.tell(), 6) # Test write() m.seek(3) m.write(b"bar") self.assertEqual(m.tell(), 6) self.assertEqual(m[:], b"012bar6789") m.write(bytearray(b"baz")) self.assertEqual(m.tell(), 9) self.assertEqual(m[:], b"012barbaz9") self.assertRaises(ValueError, m.write, b"ba") def test_non_ascii_byte(self): for b in (129, 200, 255): # > 128 m = mmap.mmap(-1, 1) m.write_byte(b) self.assertEqual(m[0], b) m.seek(0) self.assertEqual(m.read_byte(), b) m.close() @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_tagname(self): data1 = b"0123456789" data2 = b"abcdefghij" assert len(data1) == len(data2) tagname1 = random_tagname() tagname2 = random_tagname() # Test same tag m1 = mmap.mmap(-1, len(data1), tagname=tagname1) m1[:] = data1 m2 = mmap.mmap(-1, len(data2), tagname=tagname1) m2[:] = data2 self.assertEqual(m1[:], data2) self.assertEqual(m2[:], data2) m2.close() m1.close() # Test different tag m1 = mmap.mmap(-1, len(data1), tagname=tagname1) m1[:] = data1 m2 = mmap.mmap(-1, len(data2), tagname=tagname2) m2[:] = data2 self.assertEqual(m1[:], data1) self.assertEqual(m2[:], data2) m2.close() m1.close() with self.assertRaisesRegex(TypeError, 'tagname'): mmap.mmap(-1, 8, tagname=1) @cpython_only @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_sizeof(self): m1 = mmap.mmap(-1, 100) tagname = random_tagname() m2 = mmap.mmap(-1, 100, tagname=tagname) self.assertGreater(sys.getsizeof(m2), sys.getsizeof(m1)) @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_crasher_on_windows(self): # Should not crash (Issue 1733986) tagname = random_tagname() m = mmap.mmap(-1, 1000, tagname=tagname) try: mmap.mmap(-1, 5000, tagname=tagname)[:] # same tagname, but larger size except: pass m.close() # Should not crash (Issue 5385) with open(TESTFN, "wb") as fp: fp.write(b"x"*10) f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), 0) f.close() try: m.resize(0) # will raise OSError except: pass try: m[:] except: pass m.close() @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_invalid_descriptor(self): # socket file descriptors are valid, but out of range # for _get_osfhandle, causing a crash when validating the # parameters to _get_osfhandle. s = socket.socket() try: with self.assertRaises(OSError): m = mmap.mmap(s.fileno(), 10) finally: s.close() def test_context_manager(self): with mmap.mmap(-1, 10) as m: self.assertFalse(m.closed) self.assertTrue(m.closed) def test_context_manager_exception(self): # Test that the OSError gets passed through with self.assertRaises(Exception) as exc: with mmap.mmap(-1, 10) as m: raise OSError self.assertIsInstance(exc.exception, OSError, "wrong exception raised in context manager") self.assertTrue(m.closed, "context manager failed") def test_weakref(self): # Check mmap objects are weakrefable mm = mmap.mmap(-1, 16) wr = weakref.ref(mm) self.assertIs(wr(), mm) del mm gc_collect() self.assertIs(wr(), None) def test_write_returning_the_number_of_bytes_written(self): mm = mmap.mmap(-1, 16) self.assertEqual(mm.write(b""), 0) self.assertEqual(mm.write(b"x"), 1) self.assertEqual(mm.write(b"yz"), 2) self.assertEqual(mm.write(b"python"), 6) def test_resize_past_pos(self): m = mmap.mmap(-1, 8192) self.addCleanup(m.close) m.read(5000) try: m.resize(4096) except SystemError: self.skipTest("resizing not supported") self.assertEqual(m.read(14), b'') self.assertRaises(ValueError, m.read_byte) self.assertRaises(ValueError, m.write_byte, 42) self.assertRaises(ValueError, m.write, b'abc') def test_concat_repeat_exception(self): m = mmap.mmap(-1, 16) with self.assertRaises(TypeError): m + m with self.assertRaises(TypeError): m * 2 def test_flush_return_value(self): # mm.flush() should return None on success, raise an # exception on error under all platforms. mm = mmap.mmap(-1, 16) self.addCleanup(mm.close) mm.write(b'python') result = mm.flush() self.assertIsNone(result) if sys.platform.startswith('linux'): # 'offset' must be a multiple of mmap.PAGESIZE on Linux. # See bpo-34754 for details. self.assertRaises(OSError, mm.flush, 1, len(b'python')) def test_repr(self): open_mmap_repr_pat = re.compile( r"<mmap.mmap closed=False, " r"access=(?P<access>\S+), " r"length=(?P<length>\d+), " r"pos=(?P<pos>\d+), " r"offset=(?P<offset>\d+)>") closed_mmap_repr_pat = re.compile(r"<mmap.mmap closed=True>") mapsizes = (50, 100, 1_000, 1_000_000, 10_000_000) offsets = tuple((mapsize // 2 // mmap.ALLOCATIONGRANULARITY) * mmap.ALLOCATIONGRANULARITY for mapsize in mapsizes) for offset, mapsize in zip(offsets, mapsizes): data = b'a' * mapsize length = mapsize - offset accesses = ('ACCESS_DEFAULT', 'ACCESS_READ', 'ACCESS_COPY', 'ACCESS_WRITE') positions = (0, length//10, length//5, length//4) with open(TESTFN, "wb+") as fp: fp.write(data) fp.flush() for access, pos in itertools.product(accesses, positions): accint = getattr(mmap, access) with mmap.mmap(fp.fileno(), length, access=accint, offset=offset) as mm: mm.seek(pos) match = open_mmap_repr_pat.match(repr(mm)) self.assertIsNotNone(match) self.assertEqual(match.group('access'), access) self.assertEqual(match.group('length'), str(length)) self.assertEqual(match.group('pos'), str(pos)) self.assertEqual(match.group('offset'), str(offset)) match = closed_mmap_repr_pat.match(repr(mm)) self.assertIsNotNone(match) @unittest.skipUnless(hasattr(mmap.mmap, 'madvise'), 'needs madvise') def test_madvise(self): size = 2 * PAGESIZE m = mmap.mmap(-1, size) with self.assertRaisesRegex(ValueError, "madvise start out of bounds"): m.madvise(mmap.MADV_NORMAL, size) with self.assertRaisesRegex(ValueError, "madvise start out of bounds"): m.madvise(mmap.MADV_NORMAL, -1) with self.assertRaisesRegex(ValueError, "madvise length invalid"): m.madvise(mmap.MADV_NORMAL, 0, -1) with self.assertRaisesRegex(OverflowError, "madvise length too large"): m.madvise(mmap.MADV_NORMAL, PAGESIZE, sys.maxsize) self.assertEqual(m.madvise(mmap.MADV_NORMAL), None) self.assertEqual(m.madvise(mmap.MADV_NORMAL, PAGESIZE), None) self.assertEqual(m.madvise(mmap.MADV_NORMAL, PAGESIZE, size), None) self.assertEqual(m.madvise(mmap.MADV_NORMAL, 0, 2), None) self.assertEqual(m.madvise(mmap.MADV_NORMAL, 0, size), None) @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_resize_up_when_mapped_to_pagefile(self): """If the mmap is backed by the pagefile ensure a resize up can happen and that the original data is still in place """ start_size = PAGESIZE new_size = 2 * start_size data = bytes(random.getrandbits(8) for _ in range(start_size)) m = mmap.mmap(-1, start_size) m[:] = data m.resize(new_size) self.assertEqual(len(m), new_size) self.assertEqual(m[:start_size], data[:start_size]) @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_resize_down_when_mapped_to_pagefile(self): """If the mmap is backed by the pagefile ensure a resize down up can happen and that a truncated form of the original data is still in place """ start_size = PAGESIZE new_size = start_size // 2 data = bytes(random.getrandbits(8) for _ in range(start_size)) m = mmap.mmap(-1, start_size) m[:] = data m.resize(new_size) self.assertEqual(len(m), new_size) self.assertEqual(m[:new_size], data[:new_size]) @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_resize_fails_if_mapping_held_elsewhere(self): """If more than one mapping is held against a named file on Windows, neither mapping can be resized """ start_size = 2 * PAGESIZE reduced_size = PAGESIZE f = open(TESTFN, 'wb+') f.truncate(start_size) try: m1 = mmap.mmap(f.fileno(), start_size) m2 = mmap.mmap(f.fileno(), start_size) with self.assertRaises(OSError): m1.resize(reduced_size) with self.assertRaises(OSError): m2.resize(reduced_size) m2.close() m1.resize(reduced_size) self.assertEqual(m1.size(), reduced_size) self.assertEqual(os.stat(f.fileno()).st_size, reduced_size) finally: f.close() @unittest.skipUnless(os.name == 'nt', 'requires Windows') def test_resize_succeeds_with_error_for_second_named_mapping(self): """If a more than one mapping exists of the same name, none of them can be resized: they'll raise an Exception and leave the original mapping intact """ start_size = 2 * PAGESIZE reduced_size = PAGESIZE tagname = random_tagname() data_length = 8 data = bytes(random.getrandbits(8) for _ in range(data_length)) m1 = mmap.mmap(-1, start_size, tagname=tagname) m2 = mmap.mmap(-1, start_size, tagname=tagname) m1[:data_length] = data self.assertEqual(m2[:data_length], data) with self.assertRaises(OSError): m1.resize(reduced_size) self.assertEqual(m1.size(), start_size) self.assertEqual(m1[:data_length], data) self.assertEqual(m2[:data_length], data) def test_mmap_closed_by_int_scenarios(self): """ gh-103987: Test that mmap objects raise ValueError for closed mmap files """ class MmapClosedByIntContext: def __init__(self, access) -> None: self.access = access def __enter__(self): self.f = open(TESTFN, "w+b") self.f.write(random.randbytes(100)) self.f.flush() m = mmap.mmap(self.f.fileno(), 100, access=self.access) class X: def __index__(self): m.close() return 10 return (m, X) def __exit__(self, exc_type, exc_value, traceback): self.f.close() read_access_modes = [ mmap.ACCESS_READ, mmap.ACCESS_WRITE, mmap.ACCESS_COPY, mmap.ACCESS_DEFAULT, ] write_access_modes = [ mmap.ACCESS_WRITE, mmap.ACCESS_COPY, mmap.ACCESS_DEFAULT, ] for access in read_access_modes: with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[X()] with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[X() : 20] with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[X() : 20 : 2] with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[20 : X() : -2] with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m.read(X()) with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m.find(b"1", 1, X()) for access in write_access_modes: with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[X() : 20] = b"1" * 10 with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[X() : 20 : 2] = b"1" * 5 with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m[20 : X() : -2] = b"1" * 5 with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m.move(1, 2, X()) with MmapClosedByIntContext(access) as (m, X): with self.assertRaisesRegex(ValueError, "mmap closed or invalid"): m.write_byte(X()) class LargeMmapTests(unittest.TestCase): def setUp(self): unlink(TESTFN) def tearDown(self): unlink(TESTFN) def _make_test_file(self, num_zeroes, tail): if sys.platform[:3] == 'win' or sys.platform == 'darwin': requires('largefile', 'test requires %s bytes and a long time to run' % str(0x180000000)) f = open(TESTFN, 'w+b') try: f.seek(num_zeroes) f.write(tail) f.flush() except (OSError, OverflowError, ValueError): try: f.close() except (OSError, OverflowError): pass raise unittest.SkipTest("filesystem does not have largefile support") return f def test_large_offset(self): with self._make_test_file(0x14FFFFFFF, b" ") as f: with mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ) as m: self.assertEqual(m[0xFFFFFFF], 32) def test_large_filesize(self): with self._make_test_file(0x17FFFFFFF, b" ") as f: if sys.maxsize < 0x180000000: # On 32 bit platforms the file is larger than sys.maxsize so # mapping the whole file should fail -- Issue #16743 with self.assertRaises(OverflowError): mmap.mmap(f.fileno(), 0x180000000, access=mmap.ACCESS_READ) with self.assertRaises(ValueError): mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) with mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ) as m: self.assertEqual(m.size(), 0x180000000) # Issue 11277: mmap() with large (~4 GiB) sparse files crashes on OS X. def _test_around_boundary(self, boundary): tail = b' DEARdear ' start = boundary - len(tail) // 2 end = start + len(tail) with self._make_test_file(start, tail) as f: with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m: self.assertEqual(m[start:end], tail) @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems") def test_around_2GB(self): self._test_around_boundary(_2G) @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems") def test_around_4GB(self): self._test_around_boundary(_4G) if __name__ == '__main__': unittest.main()
Close