Skip to content

Commit 51977a8

Browse files
committed
Cleanup
1 parent 0768008 commit 51977a8

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

src/core/IronPython.Modules/_thread.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static object _set_sentinel(CodeContext context) {
139139
#endregion
140140

141141
[PythonType, PythonHidden]
142-
public class @lock {
142+
public sealed class @lock {
143143
private AutoResetEvent blockEvent;
144144
private Thread curHolder;
145145

@@ -173,10 +173,6 @@ public bool acquire(bool blocking = true, float timeout = -1) {
173173
}
174174
}
175175

176-
public void release(CodeContext/*!*/ context, [NotNone] params object[] param) {
177-
release(context);
178-
}
179-
180176
public void release(CodeContext/*!*/ context) {
181177
if (Interlocked.Exchange<Thread>(ref curHolder, null) == null) {
182178
throw PythonExceptions.CreateThrowable((PythonType)context.LanguageContext.GetModuleState("threaderror"), "lock isn't held", null);

src/core/IronPython.Modules/msvcrt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.Win32.SafeHandles;
1010
using System;
1111
using System.ComponentModel;
12+
using System.Diagnostics.CodeAnalysis;
1213
using System.IO;
1314
using System.Numerics;
1415
using System.Reflection;
@@ -19,7 +20,6 @@
1920

2021
using IronPython.Runtime;
2122
using IronPython.Runtime.Operations;
22-
using System.Diagnostics.CodeAnalysis;
2323

2424

2525
#if FEATURE_PIPES

src/core/IronPython.Modules/pwd.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77
#if FEATURE_NATIVE
88

99
using System;
10+
using System.Numerics;
1011
using System.Runtime.InteropServices;
1112

12-
using Microsoft.Scripting.Runtime;
13-
14-
using IronPython;
1513
using IronPython.Runtime;
1614
using 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)]
2219
namespace IronPython.Modules {
23-
20+
2421
public static class PythonPwd {
2522
public const string __doc__ = @"This module provides access to the Unix password database.
2623
It 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

src/core/IronPython/Runtime/Operations/StringOps.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,17 +2024,17 @@ static CodecsInfo() {
20242024
// set up well-known/often-used mappings
20252025
d["iso_8859_1"] = d["iso8859_1"] = d["8859"] = d["iso8859"]
20262026
= d["cp28591"] = d["28591"] = d["cp819"] = d["819"]
2027-
= d["latin_1"] = d["latin1"] = d["latin"] = d["l1"] = makeEncodingProxy(() => Latin1Encoding);
2027+
= d["latin_1"] = d["latin1"] = d["latin"] = d["l1"] = makeEncodingProxy(() => Latin1Encoding);
20282028
d["cp20127"] = d["us_ascii"] = d["us"] = d["ascii"] = d["646"] = makeEncodingProxy(() => Encoding.ASCII);
2029-
d["cp65000"] = d["utf_7"] = d["u7"] = d["unicode_1_1_utf_7"] = makeEncodingProxy(() => new UTF7Encoding(allowOptionals: true));
2030-
d["cp65001"] = d["utf_8"] = d["utf8"] = d["u8"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
2031-
d["utf_8_sig"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
2032-
d["utf_16le"] = d["utf_16_le"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: false, byteOrderMark: false));
2033-
d["cp1200"] = d["utf_16"] = d["utf16"] = d["u16"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true));
2034-
d["cp1201"] = d["utf_16be"] = d["utf_16_be"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: true, byteOrderMark: false));
2035-
d["utf_32le"] = d["utf_32_le"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: false, byteOrderMark: false));
2036-
d["cp12000"] = d["utf_32"] = d["utf32"] = d["u32"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true));
2037-
d["cp12001"] = d["utf_32be"] = d["utf_32_be"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: true, byteOrderMark: false));
2029+
d["cp65000"] = d["utf_7"] = d["u7"] = d["unicode_1_1_utf_7"] = makeEncodingProxy(() => new UTF7Encoding(allowOptionals: true));
2030+
d["cp65001"] = d["utf_8"] = d["utf8"] = d["u8"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
2031+
d["utf_8_sig"] = makeEncodingProxy(() => new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
2032+
d["utf_16le"] = d["utf_16_le"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: false, byteOrderMark: false));
2033+
d["cp1200"] = d["utf_16"] = d["utf16"] = d["u16"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true));
2034+
d["cp1201"] = d["utf_16be"] = d["utf_16_be"] = makeEncodingProxy(() => new UnicodeEncoding(bigEndian: true, byteOrderMark: false));
2035+
d["utf_32le"] = d["utf_32_le"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: false, byteOrderMark: false));
2036+
d["cp12000"] = d["utf_32"] = d["utf32"] = d["u32"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: !BitConverter.IsLittleEndian, byteOrderMark: true));
2037+
d["cp12001"] = d["utf_32be"] = d["utf_32_be"] = makeEncodingProxy(() => new UTF32Encoding(bigEndian: true, byteOrderMark: false));
20382038

20392039
// set up internal codecs
20402040
d["raw_unicode_escape"] = makeEncodingProxy(() => RawUnicodeEscapeEncoding);

0 commit comments

Comments
 (0)