| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,8 @@ class InstanceMethod: | |||
| 75 | 75 | id = _testcapi.instancemethod(id) | |
| 76 | 76 | testfunction = _testcapi.instancemethod(testfunction) | |
| 77 | 77 | ||
| 78 | + CURRENT_THREAD_REGEX = r'Current thread.*:\n' if not support.Py_GIL_DISABLED else r'Stack .*:\n' | ||
| 79 | + | ||
| 78 | 80 | class CAPITest(unittest.TestCase): | |
| 79 | 81 | ||
| 80 | 82 | def test_instancemethod(self): | |
@@ -234,8 +236,8 @@ def test_return_null_without_error(self): | |||
| 234 | 236 | r'Python runtime state: initialized\n' | |
| 235 | 237 | r'SystemError: <built-in function return_null_without_error> ' | |
| 236 | 238 | r'returned NULL without setting an exception\n' | |
| 237 | - r'\n' | ||
| 238 | - r'Current thread.*:\n' | ||
| 239 | + r'\n' + | ||
| 240 | + CURRENT_THREAD_REGEX + | ||
| 239 | 241 | r' File .*", line 6 in <module>\n') | |
| 240 | 242 | else: | |
| 241 | 243 | with self.assertRaises(SystemError) as cm: | |
@@ -268,8 +270,8 @@ def test_return_result_with_error(self): | |||
| 268 | 270 | r'SystemError: <built-in ' | |
| 269 | 271 | r'function return_result_with_error> ' | |
| 270 | 272 | r'returned a result with an exception set\n' | |
| 271 | - r'\n' | ||
| 272 | - r'Current thread.*:\n' | ||
| 273 | + r'\n' + | ||
| 274 | + CURRENT_THREAD_REGEX + | ||
| 273 | 275 | r' File .*, line 6 in <module>\n') | |
| 274 | 276 | else: | |
| 275 | 277 | with self.assertRaises(SystemError) as cm: | |
@@ -298,8 +300,8 @@ def test_getitem_with_error(self): | |||
| 298 | 300 | r'with an exception set\n' | |
| 299 | 301 | r'Python runtime state: initialized\n' | |
| 300 | 302 | r'ValueError: bug\n' | |
| 301 | - r'\n' | ||
| 302 | - r'Current thread .* \(most recent call first\):\n' | ||
| 303 | + r'\n' + | ||
| 304 | + CURRENT_THREAD_REGEX + | ||
| 303 | 305 | r' File .*, line 6 in <module>\n' | |
| 304 | 306 | r'\n' | |
| 305 | 307 | r'Extension modules: _testcapi \(total: 1\)\n') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,8 +101,7 @@ def check_error(self, code, lineno, fatal_error, *, | |||
| 101 | 101 | Raise an error if the output doesn't match the expected format. | |
| 102 | 102 | """ | |
| 103 | 103 | all_threads_disabled = ( | |
| 104 | - (not py_fatal_error) | ||
| 105 | - and all_threads | ||
| 104 | + all_threads | ||
| 106 | 105 | and (not sys._is_gil_enabled()) | |
| 107 | 106 | ) | |
| 108 | 107 | if all_threads and not all_threads_disabled: | |
@@ -116,12 +115,15 @@ def check_error(self, code, lineno, fatal_error, *, | |||
| 116 | 115 | if py_fatal_error: | |
| 117 | 116 | regex.append("Python runtime state: initialized") | |
| 118 | 117 | regex.append('') | |
| 119 | - if all_threads_disabled: | ||
| 118 | + if all_threads_disabled and not py_fatal_error: | ||
| 120 | 119 | regex.append("<Cannot show all threads while the GIL is disabled>") | |
| 121 | 120 | regex.append(fr'{header} \(most recent call first\):') | |
| 122 | - if garbage_collecting and not all_threads_disabled: | ||
| 123 | - regex.append(' Garbage-collecting') | ||
| 124 | - regex.append(fr' File "<string>", line {lineno} in {function}') | ||
| 121 | + if support.Py_GIL_DISABLED and py_fatal_error and not know_current_thread: | ||
| 122 | + regex.append(" <tstate is freed>") | ||
| 123 | + else: | ||
| 124 | + if garbage_collecting and not all_threads_disabled: | ||
| 125 | + regex.append(' Garbage-collecting') | ||
| 126 | + regex.append(fr' File "<string>", line {lineno} in {function}') | ||
| 125 | 127 | regex = '\n'.join(regex) | |
| 126 | 128 | ||
| 127 | 129 | if other_regex: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + :c:func:`Py_FatalError` no longer shows all threads on the :term:`free | ||
| 2 | + threaded <free threading>` build to prevent crashes. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3034,7 +3034,11 @@ _Py_FatalError_DumpTracebacks(int fd, PyInterpreterState *interp, | |||
| 3034 | 3034 | PUTS(fd, "\n"); | |
| 3035 | 3035 | ||
| 3036 | 3036 | /* display the current Python stack */ | |
| 3037 | + #ifndef Py_GIL_DISABLED | ||
| 3037 | 3038 | _Py_DumpTracebackThreads(fd, interp, tstate); | |
| 3039 | + #else | ||
| 3040 | + _Py_DumpTraceback(fd, tstate); | ||
| 3041 | + #endif | ||
| 3038 | 3042 | } | |
| 3039 | 3043 | ||
| 3040 | 3044 | /* Print the current exception (if an exception is set) with its traceback, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments