Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11635)

Delta Between Two Patch Sets: Lib/test/support.py

Issue 7652: Merge C version of decimal into py3k.
Left Patch Set: Created 7 years, 6 months ago
Right Patch Set: Created 7 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/decimal.py ('k') | Lib/test/test_decimal.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 """Supporting definitions for the Python regression tests.""" 1 """Supporting definitions for the Python regression tests."""
2 2
3 if __name__ != 'test.support': 3 if __name__ != 'test.support':
4 raise ImportError('support must be imported from the test package') 4 raise ImportError('support must be imported from the test package')
5 5
6 import contextlib 6 import contextlib
7 import errno 7 import errno
8 import functools 8 import functools
9 import gc 9 import gc
10 import socket 10 import socket
(...skipping 26 matching lines...) Expand all
37 37
38 try: 38 try:
39 import faulthandler 39 import faulthandler
40 except ImportError: 40 except ImportError:
41 faulthandler = None 41 faulthandler = None
42 42
43 try: 43 try:
44 import zlib 44 import zlib
45 except ImportError: 45 except ImportError:
46 zlib = None 46 zlib = None
47
48 try:
49 import fcntl
50 except ImportError:
51 fcntl = None
47 52
48 __all__ = [ 53 __all__ = [
49 "Error", "TestFailed", "ResourceDenied", "import_module", 54 "Error", "TestFailed", "ResourceDenied", "import_module",
50 "verbose", "use_resources", "max_memuse", "record_original_stdout", 55 "verbose", "use_resources", "max_memuse", "record_original_stdout",
51 "get_original_stdout", "unload", "unlink", "rmtree", "forget", 56 "get_original_stdout", "unload", "unlink", "rmtree", "forget",
52 "is_resource_enabled", "requires", "requires_freebsd_version", 57 "is_resource_enabled", "requires", "requires_freebsd_version",
53 "requires_linux_version", "requires_mac_ver", "find_unused_port", "bind_port ", 58 "requires_linux_version", "requires_mac_ver", "find_unused_port", "bind_port ",
54 "IPV6_ENABLED", "is_jython", "TESTFN", "HOST", "SAVEDCWD", "temp_cwd", 59 "IPV6_ENABLED", "is_jython", "TESTFN", "HOST", "SAVEDCWD", "temp_cwd",
55 "findfile", "create_empty_file", "sortdict", "check_syntax_error", "open_url resource", 60 "findfile", "create_empty_file", "sortdict", "check_syntax_error", "open_url resource",
56 "check_warnings", "CleanImport", "EnvironmentVarGuard", "TransientResource", 61 "check_warnings", "CleanImport", "EnvironmentVarGuard", "TransientResource",
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 if not faulthandler or not hasattr(faulthandler, '_file_watchdog'): 1182 if not faulthandler or not hasattr(faulthandler, '_file_watchdog'):
1178 return 1183 return
1179 try: 1184 try:
1180 rfd = os.open(self.procfile, os.O_RDONLY) 1185 rfd = os.open(self.procfile, os.O_RDONLY)
1181 except OSError as e: 1186 except OSError as e:
1182 warnings.warn('/proc not available for stats: {}'.format(e), 1187 warnings.warn('/proc not available for stats: {}'.format(e),
1183 RuntimeWarning) 1188 RuntimeWarning)
1184 sys.stderr.flush() 1189 sys.stderr.flush()
1185 return 1190 return
1186 pipe_fd, wfd = os.pipe() 1191 pipe_fd, wfd = os.pipe()
1192 # set the write end of the pipe non-blocking to avoid blocking the
1193 # watchdog thread when the consumer doesn't drain the pipe fast enough
1194 if fcntl:
1195 flags = fcntl.fcntl(wfd, fcntl.F_GETFL)
1196 fcntl.fcntl(wfd, fcntl.F_SETFL, flags|os.O_NONBLOCK)
1187 # _file_watchdog() doesn't take the GIL in its child thread, and 1197 # _file_watchdog() doesn't take the GIL in its child thread, and
1188 # therefore collects statistics timely 1198 # therefore collects statistics timely
1189 faulthandler._file_watchdog(rfd, wfd, 1.0) 1199 faulthandler._file_watchdog(rfd, wfd, 1.0)
1190 self.started = True 1200 self.started = True
1191 self.thread = threading.Thread(target=self.consumer, args=(pipe_fd,)) 1201 self.thread = threading.Thread(target=self.consumer, args=(pipe_fd,))
1192 self.thread.daemon = True 1202 self.thread.daemon = True
1193 self.thread.start() 1203 self.thread.start()
1194 1204
1195 def stop(self): 1205 def stop(self):
1196 if not self.started: 1206 if not self.started:
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 """ 1591 """
1582 stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip() 1592 stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
1583 return stderr 1593 return stderr
1584 1594
1585 def args_from_interpreter_flags(): 1595 def args_from_interpreter_flags():
1586 """Return a list of command-line arguments reproducing the current 1596 """Return a list of command-line arguments reproducing the current
1587 settings in sys.flags and sys.warnoptions.""" 1597 settings in sys.flags and sys.warnoptions."""
1588 flag_opt_map = { 1598 flag_opt_map = {
1589 'bytes_warning': 'b', 1599 'bytes_warning': 'b',
1590 'dont_write_bytecode': 'B', 1600 'dont_write_bytecode': 'B',
1601 'hash_randomization': 'R',
1591 'ignore_environment': 'E', 1602 'ignore_environment': 'E',
1592 'no_user_site': 's', 1603 'no_user_site': 's',
1593 'no_site': 'S', 1604 'no_site': 'S',
1594 'optimize': 'O', 1605 'optimize': 'O',
1595 'verbose': 'v', 1606 'verbose': 'v',
1596 } 1607 }
1597 args = [] 1608 args = []
1598 for flag, opt in flag_opt_map.items(): 1609 for flag, opt in flag_opt_map.items():
1599 v = getattr(sys.flags, flag) 1610 v = getattr(sys.flags, flag)
1600 if v > 0: 1611 if v > 0:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 def cleanup(): 1727 def cleanup():
1717 if attr_is_local: 1728 if attr_is_local:
1718 setattr(object_to_patch, attr_name, old_value) 1729 setattr(object_to_patch, attr_name, old_value)
1719 else: 1730 else:
1720 delattr(object_to_patch, attr_name) 1731 delattr(object_to_patch, attr_name)
1721 1732
1722 test_instance.addCleanup(cleanup) 1733 test_instance.addCleanup(cleanup)
1723 1734
1724 # actually override the attribute 1735 # actually override the attribute
1725 setattr(object_to_patch, attr_name, new_value) 1736 setattr(object_to_patch, attr_name, new_value)
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+