Lines Matching defs:sys
7 import sys
22 Py_DEBUG = hasattr(sys, "gettotalrefcount")
81 version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
102 args = (sys.executable, '-E') + args
103 args += ('-c', 'import sys; print(sys._xoptions)')
119 cmd = [sys.executable]
129 code = 'import sys; print(sys._xoptions)'
220 @unittest.skipIf(sys.platform == 'win32',
233 [sys.executable, "-c", code],
255 @unittest.skipIf(sys.platform == 'win32',
264 code = 'import sys, os; s=os.fsencode(sys.argv[1]); print(ascii(s))'
267 cmd = [sys.executable, '-c', code, arg]
271 cmd = [sys.executable, '-c', code, arg]
278 cmd = [sys.executable, '-X', 'utf8', '-c', code, arg]
299 @unittest.skipUnless((sys.platform == 'darwin' or
303 code = "import sys; print(ascii(sys.argv[1]))"
314 (sys.executable, "-c", code, text),
323 import sys
324 out = sys.stdout
326 err = sys.stderr
329 args = [sys.executable, '-c', code]
340 code = ("import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)"
346 code = ("import os, sys; sys.%s.write('x'); os._exit(0)"
353 # sys.stdin still works with '-u'
354 code = ("import sys; sys.stdout.write(sys.stdin.read(1))")
368 import sys
369 path = ":".join(sys.path)
371 sys.stdout.buffer.write(path)"""
377 @unittest.skipIf(sys.flags.safe_path,
378 'PYTHONSAFEPATH changes default sys.path')
386 import sys
387 path = ":".join(sys.path)
389 sys.stdout.buffer.write(path)"""
401 [sys.executable, '-i'],
421 (sys.executable, "-c", code),
427 # Issue #11272: check that sys.stdin.readline() replaces '\r\n' by '\n'
428 # on Windows (sys.stdin is opened in binary mode)
430 "import sys; print(repr(sys.stdin.readline()))",
442 import sys
445 print(3, file=sys.stderr)
446 print(4, file=sys.stderr)"""
449 if sys.platform == 'win32':
467 import os, sys, test.support
469 sys.stdout.write('x')
470 os.close(sys.stdout.fileno())"""
480 code = "import sys; sys.stdout.close()"
487 @unittest.skipIf(sys.platform == "vxworks",
491 import os, sys
493 if getattr(sys, s) is not None:
504 [sys.executable, "-E", "-c", code],
548 # Verify that sys.flags contains hash_randomization
549 code = 'import sys; print("random is", sys.flags.hash_randomization)'
569 print("import sys", file=script)
570 print("del sys.modules['__main__']", file=script)
597 'from sys import flags as f; '
613 [sys.executable, '-E', main], cwd=tmpdir,
615 out = subprocess.check_output([sys.executable, "-I", main],
630 "import sys; "
631 "sys.stderr.write(str(sys.flags)); "
632 f"""sys.exit(not (
633 sys.flags.debug == sys.flags.optimize ==
634 sys.flags.verbose ==
636 and sys.flags.dont_write_bytecode == {dont_write_bytecode}
643 # sys.pycache_prefix can be set from either -X pycache_prefix or
647 # (PYTHONPYCACHEPREFIX, -X pycache_prefix, sys.pycache_prefix)
657 code = f"import sys; sys.exit(not sys.pycache_prefix {exp_clause})"
675 args = (sys.executable, '-X', 'dev', *args)
677 args = (sys.executable, *args)
688 # sys.flags.dev_mode
689 code = "import sys; print(sys.flags.dev_mode)"
748 code = ("import sys; from test.support.import_helper import "
752 code = "import sys, warnings; "
755 args = (sys.executable, '-W', cmdline_option, '-bb', '-c', code)
796 args = (sys.executable, '-c', code)
833 code = "import sys; print(sys.flags.dev_mode)"
836 args = (sys.executable, '-c', code)
849 @unittest.skipUnless(sys.platform == 'win32',
852 args = sys.executable, '-c', 'print(0)'
853 prefix, exe = os.path.split(sys.executable)
862 args = [sys.executable, '-I', '--unknown-option']
872 code = "import sys; print(sys.flags.int_max_str_digits, sys.get_int_max_str_digits())"
888 self.assertEqual(res2int(res), (-1, sys.get_int_max_str_digits()))
916 code = "import sys; sys.stderr.write(str(sys.flags)); sys.exit(not ({}))".format(predicate)
921 self.run_ignoring_vars("'{}' not in sys.path".format(path),
925 self.run_ignoring_vars("sys.flags.hash_randomization == 1",
931 (sys.flags.debug == sys.flags.optimize ==
932 sys.flags.dont_write_bytecode ==
933 sys.flags.verbose == sys.flags.safe_path == 0)
947 proc = subprocess.run([sys.executable, "-"], input=code,