mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-25872: Add unit tests for linecache and threading (GH-25913) (GH-26212)
(cherry picked from commit 115dea9e26)
Co-authored-by: uniocto <serit142sa33go@gmail.com>
This commit is contained in:
parent
a44bb6ddb1
commit
373741a97c
2 changed files with 60 additions and 1 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import test.support
|
||||
from test.support import threading_helper
|
||||
from test.support import verbose, cpython_only
|
||||
from test.support import verbose, cpython_only, os_helper
|
||||
from test.support.import_helper import import_module
|
||||
from test.support.script_helper import assert_python_ok, assert_python_failure
|
||||
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
import subprocess
|
||||
import signal
|
||||
import textwrap
|
||||
import traceback
|
||||
|
||||
from unittest import mock
|
||||
from test import lock_tests
|
||||
|
|
@ -1345,6 +1346,22 @@ def run(self):
|
|||
# explicitly break the reference cycle to not leak a dangling thread
|
||||
thread.exc = None
|
||||
|
||||
def test_multithread_modify_file_noerror(self):
|
||||
# See issue25872
|
||||
def modify_file():
|
||||
with open(os_helper.TESTFN, 'w', encoding='utf-8') as fp:
|
||||
fp.write(' ')
|
||||
traceback.format_stack()
|
||||
|
||||
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
||||
threads = [
|
||||
threading.Thread(target=modify_file)
|
||||
for i in range(100)
|
||||
]
|
||||
for t in threads:
|
||||
t.start()
|
||||
t.join()
|
||||
|
||||
|
||||
class ThreadRunFail(threading.Thread):
|
||||
def run(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue