77#if FEATURE_NATIVE
88
99using System ;
10+ using System . Numerics ;
1011using System . Runtime . InteropServices ;
1112
12- using Microsoft . Scripting . Runtime ;
13-
14- using IronPython ;
1513using IronPython . Runtime ;
1614using IronPython . Runtime . Operations ;
1715
18- using System . Numerics ;
19- using System . Diagnostics . CodeAnalysis ;
16+ using Microsoft . Scripting . Runtime ;
2017
2118[ assembly: PythonModule ( "pwd" , typeof ( IronPython . Modules . PythonPwd ) , PlatformsAttribute . PlatformFamily . Unix ) ]
2219namespace IronPython . Modules {
23-
20+
2421 public static class PythonPwd {
2522 public const string __doc__ = @"This module provides access to the Unix password database.
2623It is available on all Unix versions.
@@ -133,11 +130,11 @@ public static struct_passwd getpwuid(object? uid) {
133130
134131 if ( uid is int id ) {
135132 var pwd = _getpwuid ( id ) ;
136- if ( pwd == IntPtr . Zero ) {
133+ if ( pwd == IntPtr . Zero ) {
137134 throw PythonOps . KeyError ( $ "getpwuid(): uid not found: { id } ") ;
138135 }
139136
140- return Make ( pwd ) ;
137+ return Make ( pwd ) ;
141138 }
142139
143140 throw PythonOps . TypeError ( $ "integer argument expected, got { PythonOps . GetPythonTypeName ( uid ) } ") ;
@@ -146,7 +143,7 @@ public static struct_passwd getpwuid(object? uid) {
146143 [ Documentation ( "Return the password database entry for the given user name." ) ]
147144 public static struct_passwd getpwnam ( [ NotNone ] string name ) {
148145 var pwd = _getpwnam ( name ) ;
149- if ( pwd == IntPtr . Zero ) {
146+ if ( pwd == IntPtr . Zero ) {
150147 throw PythonOps . KeyError ( $ "getpwname(): name not found: { name } ") ;
151148 }
152149
@@ -158,31 +155,32 @@ public static PythonList getpwall() {
158155 var res = new PythonList ( ) ;
159156 setpwent ( ) ;
160157 IntPtr val = getpwent ( ) ;
161- while ( val != IntPtr . Zero ) {
158+ while ( val != IntPtr . Zero ) {
162159 res . Add ( Make ( val ) ) ;
163160 val = getpwent ( ) ;
164161 }
165-
162+
166163 return res ;
167164 }
168165
169166
170167 #region P/Invoke Declarations
171168
172- [ DllImport ( "libc" , EntryPoint = "getpwuid" , CallingConvention = CallingConvention . Cdecl ) ]
169+ [ DllImport ( "libc" , EntryPoint = "getpwuid" , CallingConvention = CallingConvention . Cdecl ) ]
173170 private static extern IntPtr _getpwuid ( int uid ) ;
174171
175- [ DllImport ( "libc" , EntryPoint = "getpwnam" , CallingConvention = CallingConvention . Cdecl ) ]
172+ [ DllImport ( "libc" , EntryPoint = "getpwnam" , CallingConvention = CallingConvention . Cdecl ) ]
176173 private static extern IntPtr _getpwnam ( [ MarshalAs ( UnmanagedType . LPStr ) ] string name ) ;
177174
178- [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl ) ]
175+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl ) ]
179176 private static extern void setpwent ( ) ;
180177
181- [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl ) ]
178+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl ) ]
182179 private static extern IntPtr getpwent ( ) ;
183180
184181 #endregion
185182
186183 }
187184}
185+
188186#endif
0 commit comments