mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix Pyston speedups (#281)
We remove (i.e. hide behind a debug ifdef) the recursion checking methods, and the memory hooks and memory allocator methods. ASAN mode has no PYMALLOC, so we need a macro. Fix build break with des.c stack allocation.
This commit is contained in:
parent
2fe8571010
commit
57f0eed382
42 changed files with 260 additions and 63 deletions
3
third_party/python/Lib/test/list_tests.py
vendored
3
third_party/python/Lib/test/list_tests.py
vendored
|
@ -4,6 +4,8 @@ Tests common to list and UserList.UserList
|
|||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
import cosmo
|
||||
from functools import cmp_to_key
|
||||
|
||||
from test import support, seq_tests
|
||||
|
@ -53,6 +55,7 @@ class CommonTest(seq_tests.CommonTest):
|
|||
self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
|
||||
self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_repr_deep(self):
|
||||
a = self.type2test([])
|
||||
for i in range(sys.getrecursionlimit() + 100):
|
||||
|
|
2
third_party/python/Lib/test/mapping_tests.py
vendored
2
third_party/python/Lib/test/mapping_tests.py
vendored
|
@ -2,6 +2,7 @@
|
|||
import unittest
|
||||
import collections
|
||||
import sys
|
||||
import cosmo
|
||||
|
||||
|
||||
class BasicTestMappingProtocol(unittest.TestCase):
|
||||
|
@ -620,6 +621,7 @@ class TestHashMappingProtocol(TestMappingProtocol):
|
|||
d = self._full_mapping({1: BadRepr()})
|
||||
self.assertRaises(Exc, repr, d)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_repr_deep(self):
|
||||
d = self._empty_mapping()
|
||||
for i in range(sys.getrecursionlimit() + 100):
|
||||
|
|
3
third_party/python/Lib/test/pickletester.py
vendored
3
third_party/python/Lib/test/pickletester.py
vendored
|
@ -1943,8 +1943,7 @@ class AbstractPickleTests(unittest.TestCase):
|
|||
self.assertEqual(y._reduce_called, 1)
|
||||
|
||||
@no_tracing
|
||||
@unittest.skipIf(cosmo.MODE in ("asan", "dbg"),
|
||||
"extremely slow in asan mode")
|
||||
@unittest.skipIf(True, "disabled recursion checking + slow in asan, dbg")
|
||||
def test_bad_getattr(self):
|
||||
# Issue #3514: crash when there is an infinite loop in __getattr__
|
||||
x = BadGetattr()
|
||||
|
|
5
third_party/python/Lib/test/test_capi.py
vendored
5
third_party/python/Lib/test/test_capi.py
vendored
|
@ -1,6 +1,7 @@
|
|||
# Run the _testcapi module tests (tests for the Python/C API): by defn,
|
||||
# these are all functions _testcapi exports whose name begins with 'test_'.
|
||||
|
||||
import cosmo
|
||||
import os
|
||||
import pickle
|
||||
import random
|
||||
|
@ -179,6 +180,7 @@ class CAPITest(unittest.TestCase):
|
|||
o @= m1
|
||||
self.assertEqual(o, ("matmul", 42, m1))
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion check")
|
||||
def test_return_null_without_error(self):
|
||||
# Issue #23571: A function must not return NULL without setting an
|
||||
# error
|
||||
|
@ -207,6 +209,7 @@ class CAPITest(unittest.TestCase):
|
|||
'return_null_without_error.* '
|
||||
'returned NULL without setting an error')
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion check")
|
||||
def test_return_result_with_error(self):
|
||||
# Issue #23571: A function must not return a result with an error set
|
||||
if Py_DEBUG:
|
||||
|
@ -242,6 +245,7 @@ class CAPITest(unittest.TestCase):
|
|||
def test_buildvalue_N(self):
|
||||
_testcapi.test_buildvalue_N()
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled memory hooks")
|
||||
def test_set_nomemory(self):
|
||||
code = """if 1:
|
||||
import _testcapi
|
||||
|
@ -510,6 +514,7 @@ class Test_testcapi(unittest.TestCase):
|
|||
if name.startswith('test_') and not name.endswith('_code'))
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled memory debugging")
|
||||
class PyMemDebugTests(unittest.TestCase):
|
||||
PYTHONMALLOC = 'debug'
|
||||
# '0x04c06e0' or '04C06E0'
|
||||
|
|
2
third_party/python/Lib/test/test_class.py
vendored
2
third_party/python/Lib/test/test_class.py
vendored
|
@ -1,6 +1,7 @@
|
|||
"Test the functionality of Python classes implementing operators."
|
||||
|
||||
import unittest
|
||||
import cosmo
|
||||
|
||||
|
||||
testmeths = [
|
||||
|
@ -490,6 +491,7 @@ class ClassTests(unittest.TestCase):
|
|||
self.assertRaises(TypeError, hash, C2())
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def testSFBug532646(self):
|
||||
# Test for SF bug 532646
|
||||
|
||||
|
|
16
third_party/python/Lib/test/test_copy.py
vendored
16
third_party/python/Lib/test/test_copy.py
vendored
|
@ -1,5 +1,6 @@
|
|||
"""Unit tests for the copy module."""
|
||||
|
||||
import cosmo
|
||||
import copy
|
||||
import copyreg
|
||||
import weakref
|
||||
|
@ -372,8 +373,9 @@ class TestCopy(unittest.TestCase):
|
|||
x = []
|
||||
x.append(x)
|
||||
y = copy.deepcopy(x)
|
||||
for op in comparisons:
|
||||
self.assertRaises(RecursionError, op, y, x)
|
||||
if cosmo.MODE == "dbg": # requires recursion checking
|
||||
for op in comparisons:
|
||||
self.assertRaises(RecursionError, op, y, x)
|
||||
self.assertIsNot(y, x)
|
||||
self.assertIs(y[0], y)
|
||||
self.assertEqual(len(y), 1)
|
||||
|
@ -399,8 +401,9 @@ class TestCopy(unittest.TestCase):
|
|||
x = ([],)
|
||||
x[0].append(x)
|
||||
y = copy.deepcopy(x)
|
||||
for op in comparisons:
|
||||
self.assertRaises(RecursionError, op, y, x)
|
||||
if cosmo.MODE == "dbg": # requires recursion checking
|
||||
for op in comparisons:
|
||||
self.assertRaises(RecursionError, op, y, x)
|
||||
self.assertIsNot(y, x)
|
||||
self.assertIsNot(y[0], x[0])
|
||||
self.assertIs(y[0][0], y)
|
||||
|
@ -418,8 +421,9 @@ class TestCopy(unittest.TestCase):
|
|||
y = copy.deepcopy(x)
|
||||
for op in order_comparisons:
|
||||
self.assertRaises(TypeError, op, y, x)
|
||||
for op in equality_comparisons:
|
||||
self.assertRaises(RecursionError, op, y, x)
|
||||
if cosmo.MODE == "dbg": # requires recursion checking
|
||||
for op in equality_comparisons:
|
||||
self.assertRaises(RecursionError, op, y, x)
|
||||
self.assertIsNot(y, x)
|
||||
self.assertIs(y['foo'], y)
|
||||
self.assertEqual(len(y), 1)
|
||||
|
|
3
third_party/python/Lib/test/test_descr.py
vendored
3
third_party/python/Lib/test/test_descr.py
vendored
|
@ -5,6 +5,7 @@ import itertools
|
|||
import math
|
||||
import pickle
|
||||
import sys
|
||||
import cosmo
|
||||
import types
|
||||
import unittest
|
||||
import warnings
|
||||
|
@ -3469,6 +3470,7 @@ order (MRO) for bases """
|
|||
list.__init__(a, sequence=[0, 1, 2])
|
||||
self.assertEqual(a, [0, 1, 2])
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursive_call(self):
|
||||
# Testing recursive __call__() by setting to instance of class...
|
||||
class A(object):
|
||||
|
@ -4494,6 +4496,7 @@ order (MRO) for bases """
|
|||
with self.assertRaises(TypeError):
|
||||
str.__add__(fake_str, "abc")
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_repr_as_str(self):
|
||||
# Issue #11603: crash or infinite loop when rebinding __str__ as
|
||||
# __repr__.
|
||||
|
|
8
third_party/python/Lib/test/test_dict.py
vendored
8
third_party/python/Lib/test/test_dict.py
vendored
|
@ -469,6 +469,7 @@ class DictTest(unittest.TestCase):
|
|||
d = {1: BadRepr()}
|
||||
self.assertRaises(Exc, repr, d)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_repr_deep(self):
|
||||
d = {}
|
||||
for i in range(sys.getrecursionlimit() + 100):
|
||||
|
@ -1221,11 +1222,12 @@ class CAPITest(unittest.TestCase):
|
|||
self.assertEqual(dict_getitem_knownhash(d, 'y', hash('y')), 2)
|
||||
self.assertEqual(dict_getitem_knownhash(d, 'z', hash('z')), 3)
|
||||
|
||||
# # TODO: Did this break? What did this do?
|
||||
# # TODO: Did this break? What did this do?
|
||||
# (likely related to disabling BadInternalCall in #264)
|
||||
# # not a dict
|
||||
# # find the APE compilation mode, run this test in dbg only #
|
||||
# if cosmo.MODE == "dbg":
|
||||
# self.assertRaises(SystemError, dict_getitem_knownhash, [], 1, hash(1))
|
||||
if cosmo.MODE == "dbg":
|
||||
self.assertRaises(SystemError, dict_getitem_knownhash, [], 1, hash(1))
|
||||
|
||||
# key does not exist
|
||||
self.assertRaises(KeyError, dict_getitem_knownhash, {}, 1, hash(1))
|
||||
|
|
|
@ -2,6 +2,7 @@ import collections
|
|||
import copy
|
||||
import pickle
|
||||
import sys
|
||||
import cosmo
|
||||
import unittest
|
||||
|
||||
class DictSetTest(unittest.TestCase):
|
||||
|
@ -213,6 +214,7 @@ class DictSetTest(unittest.TestCase):
|
|||
# Again.
|
||||
self.assertIsInstance(r, str)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_deeply_nested_repr(self):
|
||||
d = {}
|
||||
for i in range(sys.getrecursionlimit() + 100):
|
||||
|
|
22
third_party/python/Lib/test/test_exceptions.py
vendored
22
third_party/python/Lib/test/test_exceptions.py
vendored
|
@ -515,6 +515,7 @@ class ExceptionTests(unittest.TestCase):
|
|||
self.assertEqual(x.fancy_arg, 42)
|
||||
|
||||
@no_tracing
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def testInfiniteRecursion(self):
|
||||
def f():
|
||||
return f()
|
||||
|
@ -928,15 +929,17 @@ class ExceptionTests(unittest.TestCase):
|
|||
else:
|
||||
self.fail("Should have raised KeyError")
|
||||
|
||||
def g():
|
||||
try:
|
||||
return g()
|
||||
except RecursionError:
|
||||
return sys.exc_info()
|
||||
e, v, tb = g()
|
||||
self.assertTrue(isinstance(v, RecursionError), type(v))
|
||||
self.assertIn("maximum recursion depth exceeded", str(v))
|
||||
if cosmo.MODE == "dbg":
|
||||
def g():
|
||||
try:
|
||||
return g()
|
||||
except RecursionError:
|
||||
return sys.exc_info()
|
||||
e, v, tb = g()
|
||||
self.assertTrue(isinstance(v, RecursionError), type(v))
|
||||
self.assertIn("maximum recursion depth exceeded", str(v))
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
@cpython_only
|
||||
def test_recursion_normalizing_exception(self):
|
||||
# Issue #22898.
|
||||
|
@ -1014,6 +1017,7 @@ class ExceptionTests(unittest.TestCase):
|
|||
b'while normalizing an exception', err)
|
||||
self.assertIn(b'Done.', out)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
@cpython_only
|
||||
def test_recursion_normalizing_with_no_memory(self):
|
||||
# Issue #30697. Test that in the abort that occurs when there is no
|
||||
|
@ -1119,6 +1123,7 @@ class ExceptionTests(unittest.TestCase):
|
|||
self.assertEqual(wr(), None)
|
||||
|
||||
@no_tracing
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursion_error_cleanup(self):
|
||||
# Same test as above, but with "recursion exceeded" errors
|
||||
class C:
|
||||
|
@ -1208,6 +1213,7 @@ class ExceptionTests(unittest.TestCase):
|
|||
self.assertIn("test message", report)
|
||||
self.assertTrue(report.endswith("\n"))
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled memory hooks")
|
||||
@cpython_only
|
||||
def test_memory_error_in_PyErr_PrintEx(self):
|
||||
code = """if 1:
|
||||
|
|
1
third_party/python/Lib/test/test_fileio.py
vendored
1
third_party/python/Lib/test/test_fileio.py
vendored
|
@ -177,6 +177,7 @@ class AutoFileTests:
|
|||
finally:
|
||||
os.close(fd)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def testRecursiveRepr(self):
|
||||
# Issue #25455
|
||||
with swap_attr(self.f, 'name', self.f):
|
||||
|
|
18
third_party/python/Lib/test/test_functools.py
vendored
18
third_party/python/Lib/test/test_functools.py
vendored
|
@ -217,6 +217,7 @@ class TestPartial:
|
|||
[f'{name}({capture!r}, {args_repr}, {kwargs_repr})'
|
||||
for kwargs_repr in kwargs_reprs])
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursive_repr(self):
|
||||
if self.partial in (c_functools.partial, py_functools.partial):
|
||||
name = 'functools.partial'
|
||||
|
@ -329,14 +330,15 @@ class TestPartial:
|
|||
|
||||
def test_recursive_pickle(self):
|
||||
with self.AllowPickle():
|
||||
f = self.partial(capture)
|
||||
f.__setstate__((f, (), {}, {}))
|
||||
try:
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
with self.assertRaises(RecursionError):
|
||||
pickle.dumps(f, proto)
|
||||
finally:
|
||||
f.__setstate__((capture, (), {}, {}))
|
||||
if cosmo.MODE == "dbg":
|
||||
f = self.partial(capture)
|
||||
f.__setstate__((f, (), {}, {}))
|
||||
try:
|
||||
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
||||
with self.assertRaises(RecursionError):
|
||||
pickle.dumps(f, proto)
|
||||
finally:
|
||||
f.__setstate__((capture, (), {}, {}))
|
||||
|
||||
f = self.partial(capture)
|
||||
f.__setstate__((capture, (f,), {}, {}))
|
||||
|
|
3
third_party/python/Lib/test/test_io.py
vendored
3
third_party/python/Lib/test/test_io.py
vendored
|
@ -28,6 +28,7 @@ import pickle
|
|||
import random
|
||||
import signal
|
||||
import sys
|
||||
import cosmo
|
||||
import time
|
||||
import unittest
|
||||
import warnings
|
||||
|
@ -1099,6 +1100,7 @@ class CommonBufferedTests:
|
|||
raw.name = b"dummy"
|
||||
self.assertEqual(repr(b), "<%s name=b'dummy'>" % clsname)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursive_repr(self):
|
||||
# Issue #25455
|
||||
raw = self.MockRawIO()
|
||||
|
@ -2540,6 +2542,7 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
t.buffer.detach()
|
||||
repr(t) # Should not raise an exception
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursive_repr(self):
|
||||
# Issue #25455
|
||||
raw = self.BytesIO()
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import unittest
|
||||
import sys
|
||||
import cosmo
|
||||
|
||||
|
||||
|
||||
|
@ -257,11 +258,13 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
|
|||
self.assertEqual(True, issubclass(int, (int, (float, int))))
|
||||
self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str))))
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_subclass_recursion_limit(self):
|
||||
# make sure that issubclass raises RecursionError before the C stack is
|
||||
# blown
|
||||
self.assertRaises(RecursionError, blowstack, issubclass, str, str)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_isinstance_recursion_limit(self):
|
||||
# make sure that issubclass raises RecursionError before the C stack is
|
||||
# blown
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
from test.test_json import PyTest, CTest
|
||||
import unittest
|
||||
import cosmo
|
||||
|
||||
|
||||
class JSONTestObject:
|
||||
|
@ -65,6 +67,7 @@ class TestRecursion:
|
|||
self.fail("didn't raise ValueError on default recursion")
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_highly_nested_objects_decoding(self):
|
||||
# test that loading highly-nested objects doesn't segfault when C
|
||||
# accelerations are used. See #12017
|
||||
|
@ -75,6 +78,7 @@ class TestRecursion:
|
|||
with self.assertRaises(RecursionError):
|
||||
self.loads('[' * 100000 + '1' + ']' * 100000)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_highly_nested_objects_encoding(self):
|
||||
# See #12051
|
||||
l, d = [], {}
|
||||
|
@ -85,6 +89,7 @@ class TestRecursion:
|
|||
with self.assertRaises(RecursionError):
|
||||
self.dumps(d)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_endless_recursion(self):
|
||||
# See #12051
|
||||
class EndlessJSONEncoder(self.json.JSONEncoder):
|
||||
|
|
2
third_party/python/Lib/test/test_plistlib.py
vendored
2
third_party/python/Lib/test/test_plistlib.py
vendored
|
@ -1,5 +1,6 @@
|
|||
# Copyright (C) 2003-2013 Python Software Foundation
|
||||
|
||||
import cosmo
|
||||
import struct
|
||||
import unittest
|
||||
import plistlib
|
||||
|
@ -813,6 +814,7 @@ class TestBinaryPlistlib(unittest.TestCase):
|
|||
b = plistlib.loads(plistlib.dumps(a, fmt=plistlib.FMT_BINARY))
|
||||
self.assertIs(b['x'], b)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_deep_nesting(self):
|
||||
for N in [300, 100000]:
|
||||
chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)]
|
||||
|
|
2
third_party/python/Lib/test/test_repl.py
vendored
2
third_party/python/Lib/test/test_repl.py
vendored
|
@ -1,6 +1,7 @@
|
|||
"""Test the interactive interpreter."""
|
||||
|
||||
import sys
|
||||
import cosmo
|
||||
import os
|
||||
import unittest
|
||||
import subprocess
|
||||
|
@ -36,6 +37,7 @@ def spawn_repl(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
|
|||
|
||||
class TestInteractiveInterpreter(unittest.TestCase):
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled memory hooks")
|
||||
@cpython_only
|
||||
def test_no_memory(self):
|
||||
# Issue #30696: Fix the interactive interpreter looping endlessly when
|
||||
|
|
2
third_party/python/Lib/test/test_richcmp.py
vendored
2
third_party/python/Lib/test/test_richcmp.py
vendored
|
@ -1,6 +1,7 @@
|
|||
# Tests for rich comparisons
|
||||
|
||||
import unittest
|
||||
import cosmo
|
||||
from test import support
|
||||
|
||||
import operator
|
||||
|
@ -220,6 +221,7 @@ class MiscTest(unittest.TestCase):
|
|||
for func in (do, operator.not_):
|
||||
self.assertRaises(Exc, func, Bad())
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
@support.no_tracing
|
||||
def test_recursion(self):
|
||||
# Check that comparison for recursive objects fails gracefully
|
||||
|
|
2
third_party/python/Lib/test/test_runpy.py
vendored
2
third_party/python/Lib/test/test_runpy.py
vendored
|
@ -3,6 +3,7 @@ import unittest
|
|||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import cosmo
|
||||
import re
|
||||
import tempfile
|
||||
import importlib, importlib.machinery, importlib.util
|
||||
|
@ -723,6 +724,7 @@ class RunPathTestCase(unittest.TestCase, CodeExecutionMixin):
|
|||
self._check_import_error(zip_name, msg)
|
||||
|
||||
@no_tracing
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_main_recursion_error(self):
|
||||
with temp_dir() as script_dir, temp_dir() as dummy_dir:
|
||||
mod_name = '__main__'
|
||||
|
|
5
third_party/python/Lib/test/test_sys.py
vendored
5
third_party/python/Lib/test/test_sys.py
vendored
|
@ -1,6 +1,7 @@
|
|||
import unittest, test.support
|
||||
from test.support.script_helper import assert_python_ok, assert_python_failure
|
||||
import sys, io, os
|
||||
import cosmo
|
||||
import struct
|
||||
import subprocess
|
||||
import textwrap
|
||||
|
@ -190,6 +191,7 @@ class SysModuleTest(unittest.TestCase):
|
|||
finally:
|
||||
sys.setswitchinterval(orig)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursionlimit(self):
|
||||
self.assertRaises(TypeError, sys.getrecursionlimit, 42)
|
||||
oldlimit = sys.getrecursionlimit()
|
||||
|
@ -199,6 +201,7 @@ class SysModuleTest(unittest.TestCase):
|
|||
self.assertEqual(sys.getrecursionlimit(), 10000)
|
||||
sys.setrecursionlimit(oldlimit)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursionlimit_recovery(self):
|
||||
if hasattr(sys, 'gettrace') and sys.gettrace():
|
||||
self.skipTest('fatal error if run with a trace function')
|
||||
|
@ -222,6 +225,7 @@ class SysModuleTest(unittest.TestCase):
|
|||
finally:
|
||||
sys.setrecursionlimit(oldlimit)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
@test.support.cpython_only
|
||||
def test_setrecursionlimit_recursion_depth(self):
|
||||
# Issue #25274: Setting a low recursion limit must be blocked if the
|
||||
|
@ -257,6 +261,7 @@ class SysModuleTest(unittest.TestCase):
|
|||
finally:
|
||||
sys.setrecursionlimit(oldlimit)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursionlimit_fatalerror(self):
|
||||
# A fatal error occurs if a second recursion limit is hit when recovering
|
||||
# from a first one.
|
||||
|
|
|
@ -9,6 +9,7 @@ from test.support.script_helper import assert_python_ok, assert_python_failure
|
|||
|
||||
import random
|
||||
import sys
|
||||
import cosmo
|
||||
_thread = import_module('_thread')
|
||||
threading = import_module('threading')
|
||||
import time
|
||||
|
@ -882,6 +883,7 @@ class ThreadingExceptionTests(BaseTestCase):
|
|||
lock = threading.Lock()
|
||||
self.assertRaises(RuntimeError, lock.release)
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
@unittest.skipUnless(sys.platform == 'darwin' and test.support.python_is_optimized(),
|
||||
'test macosx problem')
|
||||
def test_recursion_limit(self):
|
||||
|
|
|
@ -4,6 +4,7 @@ from collections import namedtuple
|
|||
from io import StringIO
|
||||
import linecache
|
||||
import sys
|
||||
import cosmo
|
||||
import unittest
|
||||
import re
|
||||
from test import support
|
||||
|
@ -300,6 +301,7 @@ class TracebackFormatTests(unittest.TestCase):
|
|||
])
|
||||
|
||||
# issue 26823 - Shrink recursive tracebacks
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def _check_recursive_traceback_display(self, render_exc):
|
||||
# Always show full diffs when this test fails
|
||||
# Note that rearranging things may require adjusting
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import contextlib
|
||||
import os
|
||||
import sys
|
||||
import tracemalloc
|
||||
import cosmo
|
||||
if cosmo.MODE == "dbg":
|
||||
import tracemalloc
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from test.support.script_helper import (assert_python_ok, assert_python_failure,
|
||||
|
@ -87,6 +89,7 @@ def traceback_filename(filename):
|
|||
return traceback_lineno(filename, 0)
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "requires APE debug build")
|
||||
class TestTracemallocEnabled(unittest.TestCase):
|
||||
def setUp(self):
|
||||
if tracemalloc.is_tracing():
|
||||
|
@ -297,6 +300,7 @@ class TestTracemallocEnabled(unittest.TestCase):
|
|||
self.assertEqual(exitcode, 0)
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "requires APE debug build")
|
||||
class TestSnapshot(unittest.TestCase):
|
||||
maxDiff = 4000
|
||||
|
||||
|
@ -591,6 +595,7 @@ class TestSnapshot(unittest.TestCase):
|
|||
[])
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "requires APE debug build")
|
||||
class TestFilters(unittest.TestCase):
|
||||
maxDiff = 2048
|
||||
|
||||
|
@ -802,6 +807,7 @@ class TestFilters(unittest.TestCase):
|
|||
self.assertFalse(f._match_traceback(unknown))
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "requires APE debug build")
|
||||
class TestCommandLine(unittest.TestCase):
|
||||
def test_env_var_disabled_by_default(self):
|
||||
# not tracing by default
|
||||
|
@ -874,6 +880,7 @@ class TestCommandLine(unittest.TestCase):
|
|||
assert_python_ok('-X', 'tracemalloc', '-c', code)
|
||||
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "requires APE debug build")
|
||||
@unittest.skipIf(_testcapi is None, 'need _testcapi')
|
||||
class TestCAPI(unittest.TestCase):
|
||||
maxDiff = 80 * 20
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from contextlib import contextmanager
|
||||
import linecache
|
||||
import os
|
||||
import cosmo
|
||||
from io import StringIO
|
||||
import re
|
||||
import sys
|
||||
|
@ -922,6 +923,7 @@ class CWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
|
|||
class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
|
||||
module = py_warnings
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "requires APE debug build")
|
||||
def test_tracemalloc(self):
|
||||
self.addCleanup(support.unlink, support.TESTFN)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
# For this purpose, the module-level "ET" symbol is temporarily
|
||||
# monkey-patched when running the "test_xml_etree_c" test suite.
|
||||
|
||||
import cosmo
|
||||
import copy
|
||||
import html
|
||||
import io
|
||||
|
@ -1920,6 +1921,7 @@ class BadElementTest(ElementTestCase, unittest.TestCase):
|
|||
e.extend([ET.Element('bar')])
|
||||
self.assertRaises(ValueError, e.remove, X('baz'))
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled recursion checking")
|
||||
def test_recursive_repr(self):
|
||||
# Issue #25455
|
||||
e = ET.Element('foo')
|
||||
|
|
2
third_party/python/Lib/test/test_zlib.py
vendored
2
third_party/python/Lib/test/test_zlib.py
vendored
|
@ -4,6 +4,7 @@ import binascii
|
|||
import pickle
|
||||
import random
|
||||
import sys
|
||||
import cosmo
|
||||
import zlib
|
||||
from test.support import bigmemtest, _1G, _4G
|
||||
|
||||
|
@ -707,6 +708,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
|
|||
|
||||
# Memory use of the following functions takes into account overallocation
|
||||
|
||||
@unittest.skipUnless(cosmo.MODE == "dbg", "disabled tracemalloc")
|
||||
@bigmemtest(size=_1G + 1024 * 1024, memuse=3)
|
||||
def test_big_compress_buffer(self, size):
|
||||
import tracemalloc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue