@@ -2241,7 +2241,6 @@ def __init__(self, a, *, b) -> None:
22412241
22422242 with warnings .catch_warnings (record = True ) as warnings_log :
22432243 CustomRLock (1 , b = 2 )
2244-
22452244 self .assertEqual (warnings_log , [])
22462245
22472246class EventTests (lock_tests .EventTests ):
@@ -2361,10 +2360,44 @@ def work():
23612360 thread = threading .Thread (target = work , name = name )
23622361 thread .start ()
23632362 thread .join ()
2364- if not name .isascii () and not work_name :
2365- self .skipTest (f"Platform does not support non-ASCII thread names: got empty name for { name !r} " )
2366- self .assertEqual (work_name , expected ,
2367- f"{ len (work_name )= } and { len (expected )= } " )
2363+
2364+ # Detect if running on OpenIndiana / illumos
2365+ try :
2366+ is_illumos = os .uname ().version .startswith ('illumos' )
2367+ except AttributeError :
2368+ is_illumos = False
2369+
2370+ if is_illumos :
2371+ # illumos requires ASCII-encoded thread names
2372+ if not work_name :
2373+ # name didn't get set (set_name may have failed)
2374+ self .skipTest (
2375+ f"Platform does not support non-ASCII thread names: got empty name for { name !r} "
2376+ )
2377+
2378+ work_name_bytes = (
2379+ work_name .encode ('ascii' , errors = 'ignore' )
2380+ if isinstance (work_name , str )
2381+ else work_name
2382+ )
2383+ expected_bytes = expected .encode ('ascii' , errors = 'ignore' )
2384+
2385+ self .assertEqual (
2386+ work_name_bytes ,
2387+ expected_bytes ,
2388+ f"{ len (work_name )= } and { len (expected )= } "
2389+ )
2390+
2391+ elif not name .isascii () and not work_name :
2392+ # Platform does not support non-ASCII thread names
2393+ self .skipTest (
2394+ f"Platform does not support non-ASCII thread names: got empty name for { name !r} "
2395+ )
2396+
2397+ else :
2398+ # Most platforms
2399+ self .assertEqual (work_name , expected ,
2400+ f"{ len (work_name )= } and { len (expected )= } " )
23682401
23692402 @unittest .skipUnless (hasattr (_thread , 'set_name' ), "missing _thread.set_name" )
23702403 @unittest .skipUnless (hasattr (_thread , '_get_name' ), "missing _thread._get_name" )
0 commit comments