1- #[ cfg( any(
2- unix,
3- windows,
4- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
5- ) ) ]
61pub ( crate ) use _locale:: make_module;
72
8- #[ cfg( not ( target_arch = "wasm32" ) ) ]
3+ #[ cfg( windows ) ]
94#[ repr( C ) ]
105struct lconv {
116 decimal_point : * mut libc:: c_char ,
@@ -34,16 +29,14 @@ struct lconv {
3429 int_n_sign_posn : libc:: c_char ,
3530}
3631
37- #[ cfg( not ( target_arch = "wasm32" ) ) ]
32+ #[ cfg( windows ) ]
3833extern "C" {
3934 fn localeconv ( ) -> * mut lconv ;
4035}
4136
42- #[ cfg( any(
43- unix,
44- windows,
45- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
46- ) ) ]
37+ #[ cfg( unix) ]
38+ use libc:: localeconv;
39+
4740#[ pymodule]
4841mod _locale {
4942 use rustpython_vm:: {
@@ -71,11 +64,6 @@ mod _locale {
7164 #[ pyattr]
7265 use libc:: { LC_ALL , LC_COLLATE , LC_CTYPE , LC_MONETARY , LC_NUMERIC , LC_TIME } ;
7366
74- #[ cfg( any(
75- unix,
76- windows,
77- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
78- ) ) ]
7967 #[ pyattr( name = "CHAR_MAX" ) ]
8068 fn char_max ( vm : & VirtualMachine ) -> PyIntRef {
8169 vm. ctx . new_int ( libc:: c_char:: MAX )
@@ -108,11 +96,6 @@ mod _locale {
10896 Ok ( vm. new_pyobj ( string) )
10997 }
11098
111- #[ cfg( any(
112- unix,
113- windows,
114- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
115- ) ) ]
11699 #[ pyattr( name = "Error" , once) ]
117100 fn error ( vm : & VirtualMachine ) -> PyTypeRef {
118101 vm. ctx . new_exception_type (
@@ -122,23 +105,13 @@ mod _locale {
122105 )
123106 }
124107
125- #[ cfg( any(
126- unix,
127- windows,
128- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
129- ) ) ]
130108 #[ pyfunction]
131109 fn strcoll ( string1 : PyStrRef , string2 : PyStrRef , vm : & VirtualMachine ) -> PyResult {
132110 let cstr1 = CString :: new ( string1. as_str ( ) ) . map_err ( |e| e. to_pyexception ( vm) ) ?;
133111 let cstr2 = CString :: new ( string2. as_str ( ) ) . map_err ( |e| e. to_pyexception ( vm) ) ?;
134112 Ok ( vm. new_pyobj ( unsafe { libc:: strcoll ( cstr1. as_ptr ( ) , cstr2. as_ptr ( ) ) } ) )
135113 }
136114
137- #[ cfg( any(
138- unix,
139- windows,
140- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
141- ) ) ]
142115 #[ pyfunction]
143116 fn strxfrm ( string : PyStrRef , vm : & VirtualMachine ) -> PyResult {
144117 // https://github.com/python/cpython/blob/eaae563b6878aa050b4ad406b67728b6b066220e/Modules/_localemodule.c#L390-L442
@@ -154,8 +127,8 @@ mod _locale {
154127 Ok ( vm. new_pyobj ( String :: from_utf8 ( buff) . expect ( "strxfrm returned invalid utf-8 string" ) ) )
155128 }
156129
157- #[ pyfunction( name = "localeconv" ) ]
158- fn _localeconv ( vm : & VirtualMachine ) -> PyResult < PyDictRef > {
130+ #[ pyfunction]
131+ fn localeconv ( vm : & VirtualMachine ) -> PyResult < PyDictRef > {
159132 let result = vm. ctx . new_dict ( ) ;
160133
161134 unsafe {
@@ -216,11 +189,6 @@ mod _locale {
216189 locale : OptionalArg < Option < PyStrRef > > ,
217190 }
218191
219- #[ cfg( any(
220- unix,
221- windows,
222- not( any( target_os = "ios" , target_os = "android" , target_arch = "wasm32" ) )
223- ) ) ]
224192 #[ pyfunction]
225193 fn setlocale ( args : LocaleArgs , vm : & VirtualMachine ) -> PyResult {
226194 let error = error ( vm) ;
0 commit comments