Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2685a1

Browse files
filmorlostmsu
authored andcommitted
Drop the long-deprecated CLR.* alias
1 parentffbbf17 commitd2685a1

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
internalstaticvoidSaveRuntimeData(RuntimeDataStoragestorage)
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
IntPtrclr_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
stringrealname=mod_name;
263259
stringclr_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+
IntPtrres=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-
stringmsg=$"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-
IntPtrres=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-
varmod=ManagedType.GetManagedObject(res)asModuleObject;
288-
mod?.LoadNames();
289-
}
290-
returnres;
291-
}
292-
// There was an error
293-
if(!Exceptions.ExceptionMatches(Exceptions.ImportError))
294-
{
295-
// and it was NOT an ImportError; bail out here.
296-
returnIntPtr.Zero;
274+
varmod=ManagedType.GetManagedObject(res)asModuleObject;
275+
mod?.LoadNames();
297276
}
277+
returnres;
278+
}
279+
// There was an error
280+
if(!Exceptions.ExceptionMatches(Exceptions.ImportError))
281+
{
282+
// and it was NOT an ImportError; bail out here.
283+
returnIntPtr.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-
returnIntPtr.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+
returnIntPtr.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 addCLR.<modulename> to sys.modules as well
361+
// If imported from CLR addclr.<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
privatestaticvoidRemoveClrRootModule()
493493
{
494494
varmodules=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
internalstaticIntPtrCreateType(ManagedTypeimpl,TypeclrType)
177177
{
178178
// Cleanup the type name to get rid of funny nested type names.
179-
stringname="CLR."+clrType.FullName;
179+
stringname=$"clr.{clrType.FullName}";
180180
inti=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
privatestaticPyObjectmodule;
1212

1313
privatestaticstringtestmod=
14-
"importCLR\n"+
15-
"fromCLR.Python.Test import ThreadTest\n"+
14+
"importclr\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
deftest(self,x):
1616
returnx*2
17-
17+
1818
defget_X(self):
1919
returnself._x
2020
defset_X(self,value):

‎src/tests/test_compat.py

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp