403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /Python315/Lib/test/test_free_threading/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /Python315/Lib/test/test_free_threading/test_string_template_race.py
import string
import unittest
from string import Template

from test.support import threading_helper


@threading_helper.requires_working_threading()
class TestTemplateCompileRace(unittest.TestCase):
    def test_concurrent_first_use(self):
        # Racing the lazy pattern compile must not raise a spurious ValueError
        # from recompiling an already-compiled pattern.  A throwaway subclass,
        # re-armed to the sentinel each round, keeps string.Template unmutated
        # (subclasses precompile eagerly in __init_subclass__).
        uncompiled = string._TemplatePattern
        errors = []

        def use_template(cls):
            try:
                cls("$x and ${y}").substitute(x=1, y=2)
            except Exception as e:
                errors.append(e)

        for _ in range(20):
            class T(Template):
                pass
            T.pattern = uncompiled
            T.flags = None
            threading_helper.run_concurrently(use_template, nthreads=10, args=(T,))

        self.assertEqual(errors, [], msg=f"unexpected errors: {errors}")


if __name__ == "__main__":
    unittest.main()

Youez - 2016 - github.com/yon3zu
LinuXploit