File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3214,11 +3214,17 @@ impl SetAttr for PyType {
32143214 } else {
32153215 let prev_value = zelf. attributes ( ) . remove ( attr_name) ;
32163216 if prev_value. is_none ( ) {
3217- return Err ( vm. new_attribute_error ( format ! (
3217+ let exc = vm. new_attribute_error ( format ! (
32183218 "type object '{}' has no attribute '{}'" ,
32193219 zelf. name( ) ,
32203220 attr_name,
3221- ) ) ) ;
3221+ ) ) ;
3222+ vm. set_attribute_error_context (
3223+ & exc,
3224+ zelf. to_owned ( ) . into ( ) ,
3225+ attr_name. to_owned ( ) ,
3226+ ) ;
3227+ return Err ( exc) ;
32223228 }
32233229 prev_value
32243230 } ;
Original file line number Diff line number Diff line change 11pub ( crate ) use _sysconfig:: module_def;
22
3+ #[ pymodule]
4+ pub ( crate ) mod _missing_stdlib_info {
5+ use crate :: { VirtualMachine , builtins:: PyDictRef , convert:: ToPyObject } ;
6+
7+ #[ pyattr( name = "_MISSING_STDLIB_MODULE_MESSAGES" ) ]
8+ fn missing_stdlib_module_messages ( vm : & VirtualMachine ) -> PyDictRef {
9+ let messages = vm. ctx . new_dict ( ) ;
10+ // CPython's Tools/build/check_extension_modules.py emits these entries
11+ // unconditionally, including on Windows. Do not infer disabled build
12+ // features from CPython's module inventory: ours is different.
13+ for name in [
14+ "_overlapped" ,
15+ "_testconsole" ,
16+ "_winapi" ,
17+ "_wmi" ,
18+ "msvcrt" ,
19+ "nt" ,
20+ "winreg" ,
21+ "winsound" ,
22+ ] {
23+ let message =
24+ format ! ( "Unsupported platform for Windows-only standard library module '{name}'" ) ;
25+ messages
26+ . set_item ( name, message. to_pyobject ( vm) , vm)
27+ . unwrap ( ) ;
28+ }
29+ // This module is only implemented for macOS in our stdlib as well.
30+ #[ cfg( not( target_os = "macos" ) ) ]
31+ messages
32+ . set_item (
33+ "_scproxy" ,
34+ "Unsupported platform for standard library module '_scproxy'" . to_pyobject ( vm) ,
35+ vm,
36+ )
37+ . unwrap ( ) ;
38+ messages
39+ }
40+ }
41+
342#[ pymodule]
443pub ( crate ) mod _sysconfig {
544 use crate :: { VirtualMachine , builtins:: PyDictRef , convert:: ToPyObject } ;
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ pub fn builtin_module_defs(ctx: &Context) -> Vec<&'static PyModuleDef> {
140140 _symtable:: module_def( ctx) ,
141141 _sysconfigdata:: module_def( ctx) ,
142142 _sysconfig:: module_def( ctx) ,
143+ _sysconfig:: _missing_stdlib_info:: module_def( ctx) ,
143144 #[ cfg( feature = "threading" ) ]
144145 _thread:: module_def( ctx) ,
145146 _interpchannels:: module_def( ctx) ,
You can’t perform that action at this time.
0 commit comments