Skip to content

Commit ec678f7

Browse files
committed
Refactor license, fix typo
1 parent 5631442 commit ec678f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+508
-1220
lines changed

src/clrmodule/ClrModule.cs

+9-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
9-
1+

102
//============================================================================
113
// This file replaces the hand-maintained stub that used to implement clr.dll.
124
// This is a line-by-line port from IL back to C#.
@@ -21,7 +13,7 @@
2113
// If defined, the "pythonRuntimeVersionString" variable must be set to
2214
// Python.Runtime's current version.
2315

24-
#define USE_PYTHON_RUNTIME_VERSION
16+
#define USE_PYTHON_RUNTIME_VERSION
2517

2618
// If defined, the "PythonRuntimePublicKeyTokenData" data array must be
2719
// set to Python.Runtime's public key token. (sn -T Python.Runtin.dll)
@@ -32,21 +24,21 @@
3224
//============================================================================
3325
using System;
3426

35-
// ReSharper disable CheckNamespace
36-
// ReSharper disable InconsistentNaming
27+
28+
3729
public class clrModule
38-
// ReSharper restore InconsistentNaming
39-
// ReSharper restore CheckNamespace
30+
31+
4032
{
41-
// ReSharper disable InconsistentNaming
33+
4234
#if (PYTHON32 || PYTHON33 || PYTHON34 || PYTHON35)
4335
[RGiesecke.DllExport.DllExport("PyInit_clr", System.Runtime.InteropServices.CallingConvention.StdCall)]
4436
public static IntPtr PyInit_clr()
4537
#else
4638
[RGiesecke.DllExport.DllExport("initclr", System.Runtime.InteropServices.CallingConvention.StdCall)]
4739
public static void initclr()
4840
#endif
49-
// ReSharper restore InconsistentNaming
41+
5042
{
5143
#if DEBUG_PRINT
5244
System.Console.WriteLine("Attempting to load Python.Runtime using standard binding rules... ");
@@ -64,7 +56,7 @@ public static void initclr()
6456
var pythonRuntimeName = new System.Reflection.AssemblyName("Python.Runtime")
6557
{
6658
#if USE_PYTHON_RUNTIME_VERSION
67-
Version = new System.Version("4.0.0.1"),
59+
Version = new System.Version("4.0.0.1"),
6860
#endif
6961
CultureInfo = System.Globalization.CultureInfo.InvariantCulture,
7062
};

src/console/assemblyinfo.cs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
91

102
using System;
113
using System.Reflection;
@@ -21,7 +13,7 @@
2113
[assembly: ComVisible(false)]
2214

2315

24-
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum,
16+
[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum,
2517
Name = "FullTrust")]
2618
[assembly: AssemblyDescriptionAttribute("")]
2719
[assembly: AssemblyCopyrightAttribute("Zope Public License, Version 2.0 (ZPL)")]

src/console/pythonconsole.cs

-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
91

102
using System;
113
using System.Reflection;

src/runtime/arrayobject.cs

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
91

102
using System;
113
using System.Collections;
@@ -15,7 +7,7 @@ namespace Python.Runtime {
157

168
/// <summary>
179
/// Implements a Python type for managed arrays. This type is essentially
18-
/// the same as a ClassObject, except that it provides sequence semantics
10+
/// the same as a ClassObject, except that it provides sequence semantics
1911
/// to support natural array usage (indexing) from Python.
2012
/// </summary>
2113

@@ -57,7 +49,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) {
5749
// Note that CLR 1.0 only supports int indexes - methods to
5850
// support long indices were introduced in 1.1. We could
5951
// support long indices automatically, but given that long
60-
// indices are not backward compatible and a relative edge
52+
// indices are not backward compatible and a relative edge
6153
// case, we won't bother for now.
6254

6355
// Single-dimensional arrays are the most common case and are
@@ -81,7 +73,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) {
8173
Exceptions.SetError(Exceptions.IndexError,
8274
"array index out of range"
8375
);
84-
return IntPtr.Zero;
76+
return IntPtr.Zero;
8577
}
8678

8779
return Converter.ToPython(items.GetValue(index), itemType);
@@ -122,7 +114,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) {
122114
Exceptions.SetError(Exceptions.IndexError,
123115
"array index out of range"
124116
);
125-
return IntPtr.Zero;
117+
return IntPtr.Zero;
126118
}
127119

128120
return Converter.ToPython(value, itemType);
@@ -169,7 +161,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) {
169161
Exceptions.SetError(Exceptions.IndexError,
170162
"array index out of range"
171163
);
172-
return -1;
164+
return -1;
173165
}
174166

175167
return 0;
@@ -247,6 +239,6 @@ public static int mp_length(IntPtr ob) {
247239
}
248240

249241

250-
}
242+
}
251243

252244
}

src/runtime/assemblyinfo.cs

-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
91

102
using System;
113
using System.Reflection;

src/runtime/assemblymanager.cs

+15-23
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
91

102
using System;
113
using System.IO;
@@ -19,7 +11,7 @@
1911
namespace Python.Runtime {
2012

2113
/// <summary>
22-
/// The AssemblyManager maintains information about loaded assemblies
14+
/// The AssemblyManager maintains information about loaded assemblies
2315
/// namespaces and provides an interface for name-based type lookup.
2416
/// </summary>
2517

@@ -42,7 +34,7 @@ private AssemblyManager() {}
4234
//===================================================================
4335

4436
internal static void Initialize() {
45-
namespaces = new
37+
namespaces = new
4638
Dictionary<string, Dictionary<Assembly, string>>(32);
4739
probed = new Dictionary<string, int>(32);
4840
//generics = new Dictionary<string, Dictionary<string, string>>();
@@ -54,7 +46,7 @@ internal static void Initialize() {
5446
lhandler = new AssemblyLoadEventHandler(AssemblyLoadHandler);
5547
domain.AssemblyLoad += lhandler;
5648

57-
rhandler = new ResolveEventHandler(ResolveHandler);
49+
rhandler = new ResolveEventHandler(ResolveHandler);
5850
domain.AssemblyResolve += rhandler;
5951

6052
Assembly[] items = domain.GetAssemblies();
@@ -85,10 +77,10 @@ internal static void Shutdown() {
8577

8678

8779
//===================================================================
88-
// Event handler for assembly load events. At the time the Python
80+
// Event handler for assembly load events. At the time the Python
8981
// runtime loads, we scan the app domain to map the assemblies that
9082
// are loaded at the time. We also have to register this event handler
91-
// so that we can know about assemblies that get loaded after the
83+
// so that we can know about assemblies that get loaded after the
9284
// Python runtime is initialized.
9385
//===================================================================
9486

@@ -122,11 +114,11 @@ static Assembly ResolveHandler(Object ob, ResolveEventArgs args){
122114

123115
//===================================================================
124116
// We __really__ want to avoid using Python objects or APIs when
125-
// probing for assemblies to load, since our ResolveHandler may be
117+
// probing for assemblies to load, since our ResolveHandler may be
126118
// called in contexts where we don't have the Python GIL and can't
127119
// even safely try to get it without risking a deadlock ;(
128120
//
129-
// To work around that, we update a managed copy of sys.path (which
121+
// To work around that, we update a managed copy of sys.path (which
130122
// is the main thing we care about) when UpdatePath is called. The
131123
// import hook calls this whenever it knows its about to use the
132124
// assembly manager, which lets us keep up with changes to sys.path
@@ -216,11 +208,11 @@ public static Assembly LoadAssemblyPath(string name) {
216208
return assembly;
217209
}
218210

219-
/// <summary>
220-
/// Loads an assembly using full path.
221-
/// </summary>
222-
/// <param name="name"></param>
223-
/// <returns></returns>
211+
/// <summary>
212+
/// Loads an assembly using full path.
213+
/// </summary>
214+
/// <param name="name"></param>
215+
/// <returns></returns>
224216
public static Assembly LoadAssemblyFullPath(string name) {
225217
Assembly assembly = null;
226218
if (Path.IsPathRooted(name)) {
@@ -249,7 +241,7 @@ public static Assembly FindLoadedAssembly(string name) {
249241
}
250242

251243
//===================================================================
252-
// Given a qualified name of the form A.B.C.D, attempt to load
244+
// Given a qualified name of the form A.B.C.D, attempt to load
253245
// an assembly named after each of A.B.C.D, A.B.C, A.B, A. This
254246
// will only actually probe for the assembly once for each unique
255247
// namespace. Returns true if any assemblies were loaded.
@@ -304,7 +296,7 @@ public static bool LoadImplicit(string name, bool warn=true) {
304296
//===================================================================
305297
// Scans an assembly for exported namespaces, adding them to the
306298
// mapping of valid namespaces. Note that for a given namespace
307-
// a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to
299+
// a.b.c.d, each of a, a.b, a.b.c and a.b.c.d are considered to
308300
// be valid namespaces (to better match Python import semantics).
309301
//===================================================================
310302

@@ -402,7 +394,7 @@ public static List<string> GetNames(string nsname) {
402394
//string tail = key.Substring(nslen);
403395
if (key.IndexOf('.') == -1) {
404396
names.Add(key);
405-
}
397+
}
406398
}
407399
}
408400
}

src/runtime/classbase.cs

+9-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
91

102
using System;
113
using System.Collections;
@@ -49,15 +41,15 @@ public static int tp_init(IntPtr ob, IntPtr args, IntPtr kw) {
4941
//====================================================================
5042
// Default implementation of [] semantics for reflected types.
5143
//====================================================================
52-
44+
5345
public virtual IntPtr type_subscript(IntPtr idx) {
5446
Type[] types = Runtime.PythonArgsToTypeArray(idx);
5547
if (types == null) {
5648
return Exceptions.RaiseTypeError("type(s) expected");
57-
}
58-
59-
Type target = GenericUtil.GenericForType(this.type, types.Length);
60-
49+
}
50+
51+
Type target = GenericUtil.GenericForType(this.type, types.Length);
52+
6153
if (target != null) {
6254
Type t = target.MakeGenericType(types);
6355
ManagedType c = (ManagedType)ClassManager.GetClass(t);
@@ -66,7 +58,7 @@ public virtual IntPtr type_subscript(IntPtr idx) {
6658
}
6759

6860
return Exceptions.RaiseTypeError("no type matches params");
69-
}
61+
}
7062

7163
//====================================================================
7264
// Standard comparison implementation for instances of reflected types.
@@ -151,7 +143,7 @@ public static IntPtr tp_iter(IntPtr ob) {
151143
}
152144
else {
153145
o = co.inst as IEnumerator;
154-
146+
155147
if (o == null) {
156148
string message = "iteration over non-sequence";
157149
return Exceptions.RaiseTypeError(message);
@@ -221,7 +213,7 @@ public static int tp_is_gc(IntPtr type) {
221213
public static void tp_dealloc(IntPtr ob) {
222214
ManagedType self = GetManagedObject(ob);
223215
IntPtr dict = Marshal.ReadIntPtr(ob, ObjectOffset.DictOffset(ob));
224-
if (dict != IntPtr.Zero) {
216+
if (dict != IntPtr.Zero) {
225217
Runtime.Decref(dict);
226218
}
227219
Runtime.PyObject_GC_UnTrack(self.pyHandle);
@@ -231,6 +223,6 @@ public static void tp_dealloc(IntPtr ob) {
231223
}
232224

233225

234-
}
226+
}
235227

236228
}

src/runtime/classderived.cs

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
// ==========================================================================
2-
// This software is subject to the provisions of the Zope Public License,
3-
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
4-
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
5-
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
6-
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
7-
// FOR A PARTICULAR PURPOSE.
8-
// ==========================================================================
9-
1+

102
using System;
113
using System.IO;
124
using System.Reflection;
@@ -22,8 +14,8 @@ namespace Python.Runtime
2214

2315
/// <summary>
2416
/// Managed class that provides the implementation for reflected types.
25-
/// Managed classes and value types are represented in Python by actual
26-
/// Python type objects. Each of those type objects is associated with
17+
/// Managed classes and value types are represented in Python by actual
18+
/// Python type objects. Each of those type objects is associated with
2719
/// an instance of ClassObject, which provides its implementation.
2820
/// </summary>
2921

0 commit comments

Comments
 (0)