|
18 | 18 | if not support.has_subprocess_support: |
19 | 19 | raise unittest.SkipTest("test module requires subprocess") |
20 | 20 |
|
21 | | -# Debug build? |
22 | | -Py_DEBUG = hasattr(sys, "gettotalrefcount") |
23 | | - |
24 | 21 |
|
25 | 22 | # XXX (ncoghlan): Move to script_helper and make consistent with run_python |
26 | 23 | def _kill_python_and_exit_code(p): |
@@ -144,7 +141,7 @@ def run_python(*args): |
144 | 141 | # "-X showrefcount" shows the refcount, but only in debug builds |
145 | 142 | rc, out, err = run_python('-I', '-X', 'showrefcount', '-c', code) |
146 | 143 | self.assertEqual(out.rstrip(), b"{'showrefcount': True}") |
147 | | - if Py_DEBUG: |
| 144 | + if support.Py_DEBUG: |
148 | 145 | # bpo-46417: Tolerate negative reference count which can occur |
149 | 146 | # because of bugs in C extensions. This test is only about checking |
150 | 147 | # the showrefcount feature. |
@@ -753,7 +750,7 @@ def test_xdev(self): |
753 | 750 | code = ("import warnings; " |
754 | 751 | "print(' '.join('%s::%s' % (f[0], f[2].__name__) " |
755 | 752 | "for f in warnings.filters))") |
756 | | - if Py_DEBUG: |
| 753 | + if support.Py_DEBUG: |
757 | 754 | expected_filters = "default::Warning" |
758 | 755 | else: |
759 | 756 | expected_filters = ("default::Warning " |
@@ -827,7 +824,7 @@ def test_warnings_filter_precedence(self): |
827 | 824 | expected_filters = ("error::BytesWarning " |
828 | 825 | "once::UserWarning " |
829 | 826 | "always::UserWarning") |
830 | | - if not Py_DEBUG: |
| 827 | + if not support.Py_DEBUG: |
831 | 828 | expected_filters += (" " |
832 | 829 | "default::DeprecationWarning " |
833 | 830 | "ignore::DeprecationWarning " |
@@ -867,10 +864,10 @@ def test_pythonmalloc(self): |
867 | 864 | # Test the PYTHONMALLOC environment variable |
868 | 865 | pymalloc = support.with_pymalloc() |
869 | 866 | if pymalloc: |
870 | | - default_name = 'pymalloc_debug' if Py_DEBUG else 'pymalloc' |
| 867 | + default_name = 'pymalloc_debug' if support.Py_DEBUG else 'pymalloc' |
871 | 868 | default_name_debug = 'pymalloc_debug' |
872 | 869 | else: |
873 | | - default_name = 'malloc_debug' if Py_DEBUG else 'malloc' |
| 870 | + default_name = 'malloc_debug' if support.Py_DEBUG else 'malloc' |
874 | 871 | default_name_debug = 'malloc_debug' |
875 | 872 |
|
876 | 873 | tests = [ |
@@ -950,7 +947,8 @@ def res2int(res): |
950 | 947 | return tuple(int(i) for i in out.split()) |
951 | 948 |
|
952 | 949 | res = assert_python_ok('-c', code) |
953 | | - self.assertEqual(res2int(res), (-1, sys.get_int_max_str_digits())) |
| 950 | + current_max = sys.get_int_max_str_digits() |
| 951 | + self.assertEqual(res2int(res), (current_max, current_max)) |
954 | 952 | res = assert_python_ok('-X', 'int_max_str_digits=0', '-c', code) |
955 | 953 | self.assertEqual(res2int(res), (0, 0)) |
956 | 954 | res = assert_python_ok('-X', 'int_max_str_digits=4000', '-c', code) |
|
0 commit comments