Skip to content

Commit 008c5fe

Browse files
committed
Drop the long-deprecated CLR.* alias
1 parent ffbbf17 commit 008c5fe

File tree

9 files changed

+42
-289
lines changed

9 files changed

+42
-289
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ details about the cause of the failure
2525
if you need to "downcast" to the implementation class.
2626
- BREAKING: Parameters marked with `ParameterAttributes.Out` are no longer returned in addition
2727
to the regular method return value (unless they are passed with `ref` or `out` keyword).
28+
- BREAKING: Drop support for the long-deprecated CLR.* prefix.
2829

2930
### Fixed
3031

src/runtime/importhook.cs

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ internal static void Shutdown()
124124

125125
internal static void SaveRuntimeData(RuntimeDataStorage storage)
126126
{
127-
// Increment the reference counts here so that the objects don't
127+
// Increment the reference counts here so that the objects don't
128128
// get freed in Shutdown.
129129
Runtime.XIncref(py_clr_module);
130130
Runtime.XIncref(root.pyHandle);
@@ -241,12 +241,8 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
241241
// Check these BEFORE the built-in import runs; may as well
242242
// do the Incref()ed return here, since we've already found
243243
// the module.
244-
if (mod_name == "clr" || mod_name == "CLR")
244+
if (mod_name == "clr")
245245
{
246-
if (mod_name == "CLR")
247-
{
248-
Exceptions.deprecation("The CLR module is deprecated. Please use 'clr'.");
249-
}
250246
IntPtr clr_module = GetCLRModule(fromList);
251247
if (clr_module != IntPtr.Zero)
252248
{
@@ -262,51 +258,41 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
262258
string realname = mod_name;
263259
string clr_prefix = null;
264260

265-
if (mod_name.StartsWith("CLR."))
261+
// 2010-08-15: Always seemed smart to let python try first...
262+
// This shaves off a few tenths of a second on test_module.py
263+
// and works around a quirk where 'sys' is found by the
264+
// LoadImplicit() deprecation logic.
265+
// Turns out that the AssemblyManager.ResolveHandler() checks to see if any
266+
// Assembly's FullName.ToLower().StartsWith(name.ToLower()), which makes very
267+
// little sense to me.
268+
IntPtr res = Runtime.PyObject_Call(py_import, args, kw);
269+
if (res != IntPtr.Zero)
266270
{
267-
clr_prefix = "CLR."; // prepend when adding the module to sys.modules
268-
realname = mod_name.Substring(4);
269-
string msg = $"Importing from the CLR.* namespace is deprecated. Please import '{realname}' directly.";
270-
Exceptions.deprecation(msg);
271-
}
272-
else
273-
{
274-
// 2010-08-15: Always seemed smart to let python try first...
275-
// This shaves off a few tenths of a second on test_module.py
276-
// and works around a quirk where 'sys' is found by the
277-
// LoadImplicit() deprecation logic.
278-
// Turns out that the AssemblyManager.ResolveHandler() checks to see if any
279-
// Assembly's FullName.ToLower().StartsWith(name.ToLower()), which makes very
280-
// little sense to me.
281-
IntPtr res = Runtime.PyObject_Call(py_import, args, kw);
282-
if (res != IntPtr.Zero)
271+
// There was no error.
272+
if (fromlist && IsLoadAll(fromList))
283273
{
284-
// There was no error.
285-
if (fromlist && IsLoadAll(fromList))
286-
{
287-
var mod = ManagedType.GetManagedObject(res) as ModuleObject;
288-
mod?.LoadNames();
289-
}
290-
return res;
291-
}
292-
// There was an error
293-
if (!Exceptions.ExceptionMatches(Exceptions.ImportError))
294-
{
295-
// and it was NOT an ImportError; bail out here.
296-
return IntPtr.Zero;
274+
var mod = ManagedType.GetManagedObject(res) as ModuleObject;
275+
mod?.LoadNames();
297276
}
277+
return res;
278+
}
279+
// There was an error
280+
if (!Exceptions.ExceptionMatches(Exceptions.ImportError))
281+
{
282+
// and it was NOT an ImportError; bail out here.
283+
return IntPtr.Zero;
284+
}
298285

299-
if (mod_name == string.Empty)
300-
{
301-
// Most likely a missing relative import.
302-
// For example site-packages\bs4\builder\__init__.py uses it to check if a package exists:
303-
// from . import _html5lib
304-
// We don't support them anyway
305-
return IntPtr.Zero;
306-
}
307-
// Otherwise, just clear the it.
308-
Exceptions.Clear();
286+
if (mod_name == string.Empty)
287+
{
288+
// Most likely a missing relative import.
289+
// For example site-packages\bs4\builder\__init__.py uses it to check if a package exists:
290+
// from . import _html5lib
291+
// We don't support them anyway
292+
return IntPtr.Zero;
309293
}
294+
// Otherwise, just clear the it.
295+
Exceptions.Clear();
310296

311297
string[] names = realname.Split('.');
312298

@@ -372,7 +358,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw)
372358
// Add the module to sys.modules
373359
Runtime.PyDict_SetItemString(modules, tail.moduleName, tail.pyHandle);
374360

375-
// If imported from CLR add CLR.<modulename> to sys.modules as well
361+
// If imported from CLR add clr.<modulename> to sys.modules as well
376362
if (clr_prefix != null)
377363
{
378364
Runtime.PyDict_SetItemString(modules, clr_prefix + tail.moduleName, tail.pyHandle);

src/runtime/runtime.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ private static void ClearClrModules()
492492
private static void RemoveClrRootModule()
493493
{
494494
var modules = PyImport_GetModuleDict();
495-
PyDictTryDelItem(modules, "CLR");
496495
PyDictTryDelItem(modules, "clr");
497496
PyDictTryDelItem(modules, "clr._extra");
498497
}

src/runtime/typemanager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ internal static IntPtr CreateType(Type impl)
176176
internal static IntPtr CreateType(ManagedType impl, Type clrType)
177177
{
178178
// Cleanup the type name to get rid of funny nested type names.
179-
string name = "CLR." + clrType.FullName;
179+
string name = $"clr.{clrType.FullName}";
180180
int i = name.LastIndexOf('+');
181181
if (i > -1)
182182
{

src/testing/threadtest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class ThreadTest
1111
private static PyObject module;
1212

1313
private static string testmod =
14-
"import CLR\n" +
15-
"from CLR.Python.Test import ThreadTest\n" +
14+
"import clr\n" +
15+
"from Python.Test import ThreadTest\n" +
1616
"\n" +
1717
"def echostring(value):\n" +
1818
" return value\n" +

src/tests/test_clrmethod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self):
1414
@clr.clrmethod(int, [int])
1515
def test(self, x):
1616
return x*2
17-
17+
1818
def get_X(self):
1919
return self._x
2020
def set_X(self, value):

src/tests/test_compat.py

Lines changed: 0 additions & 233 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy