@@ -4,23 +4,22 @@ pub(crate) use sys::{UnraisableHookArgs, MAXSIZE, MULTIARCH};
44
55#[ pymodule]
66mod sys {
7- use crate :: common:: {
8- ascii,
9- hash:: { PyHash , PyUHash } ,
10- } ;
117 use crate :: {
128 builtins:: { PyDictRef , PyNamespace , PyStr , PyStrRef , PyTupleRef , PyTypeRef } ,
9+ common:: {
10+ ascii,
11+ hash:: { PyHash , PyUHash } ,
12+ } ,
1313 frame:: FrameRef ,
1414 function:: { FuncArgs , OptionalArg , PosArgs } ,
15- stdlib:: builtins,
15+ stdlib:: { self , builtins} ,
1616 types:: PyStructSequence ,
1717 version,
1818 vm:: { Settings , VirtualMachine } ,
1919 AsObject , PyObjectRef , PyRef , PyRefExact , PyResult ,
2020 } ;
2121 use num_traits:: ToPrimitive ;
22- use std:: sync:: atomic:: Ordering ;
23- use std:: { env, mem, path} ;
22+ use std:: { env, mem, path, sync:: atomic:: Ordering } ;
2423
2524 // not the same as CPython (e.g. rust's x86_x64-unknown-linux-gnu is just x86_64-linux-gnu)
2625 // but hopefully that's just an implementation detail? TODO: copy CPython's multiarch exactly,
@@ -562,6 +561,12 @@ mod sys {
562561 update_use_tracing ( vm) ;
563562 }
564563
564+ #[ cfg( feature = "threading" ) ]
565+ #[ pyattr]
566+ fn thread_info ( vm : & VirtualMachine ) -> PyTupleRef {
567+ PyThreadInfo :: INFO . into_struct_sequence ( vm)
568+ }
569+
565570 #[ pyattr]
566571 fn version_info ( vm : & VirtualMachine ) -> PyTupleRef {
567572 VersionInfo :: VERSION . into_struct_sequence ( vm)
@@ -643,6 +648,27 @@ mod sys {
643648 }
644649 }
645650
651+ #[ cfg( feature = "threading" ) ]
652+ #[ pyclass( noattr, name = "thread_info" ) ]
653+ #[ derive( PyStructSequence ) ]
654+ pub ( super ) struct PyThreadInfo {
655+ name : Option < & ' static str > ,
656+ lock : Option < & ' static str > ,
657+ version : Option < & ' static str > ,
658+ }
659+
660+ #[ cfg( feature = "threading" ) ]
661+ #[ pyclass( with( PyStructSequence ) ) ]
662+ impl PyThreadInfo {
663+ const INFO : Self = PyThreadInfo {
664+ name : stdlib:: thread:: _thread:: PYTHREAD_NAME ,
665+ /// As I know, there's only way to use lock as "Mutex" in Rust
666+ /// with satisfying python document spec.
667+ lock : Some ( "mutex+cond" ) ,
668+ version : None ,
669+ } ;
670+ }
671+
646672 #[ pyclass( noattr, name = "float_info" ) ]
647673 #[ derive( PyStructSequence ) ]
648674 pub ( super ) struct PyFloatInfo {
@@ -658,6 +684,7 @@ mod sys {
658684 radix : u32 ,
659685 rounds : i32 ,
660686 }
687+
661688 #[ pyclass( with( PyStructSequence ) ) ]
662689 impl PyFloatInfo {
663690 const INFO : Self = PyFloatInfo {
@@ -713,6 +740,7 @@ mod sys {
713740 bits_per_digit : usize ,
714741 sizeof_digit : usize ,
715742 }
743+
716744 #[ pyclass( with( PyStructSequence ) ) ]
717745 impl PyIntInfo {
718746 const INFO : Self = PyIntInfo {
@@ -765,6 +793,7 @@ mod sys {
765793 product_type : u8 ,
766794 platform_version : ( u32 , u32 , u32 ) ,
767795 }
796+
768797 #[ cfg( windows) ]
769798 #[ pyclass( with( PyStructSequence ) ) ]
770799 impl WindowsVersion { }
0 commit comments