| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ffbbf17 commit d2685a1
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ details about the cause of the failure | |||
| 25 | 25 | if you need to "downcast" to the implementation class. | |
| 26 | 26 | - BREAKING: Parameters marked with `ParameterAttributes.Out` are no longer returned in addition | |
| 27 | 27 | 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. | ||
| 28 | 29 | ||
| 29 | 30 | ### Fixed | |
| 30 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,7 +124,7 @@ internal static void Shutdown() | |||
| 124 | 124 | ||
| 125 | 125 | internal static void SaveRuntimeData(RuntimeDataStorage storage) | |
| 126 | 126 | { | |
| 127 | - // Increment the reference counts here so that the objects don't | ||
| 127 | + // Increment the reference counts here so that the objects don't | ||
| 128 | 128 | // get freed in Shutdown. | |
| 129 | 129 | Runtime.XIncref(py_clr_module); | |
| 130 | 130 | Runtime.XIncref(root.pyHandle); | |
@@ -241,12 +241,8 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) | |||
| 241 | 241 | // Check these BEFORE the built-in import runs; may as well | |
| 242 | 242 | // do the Incref()ed return here, since we've already found | |
| 243 | 243 | // the module. | |
| 244 | - if (mod_name == "clr" || mod_name == "CLR") | ||
| 244 | + if (mod_name == "clr") | ||
| 245 | 245 | { | |
| 246 | - if (mod_name == "CLR") | ||
| 247 | - { | ||
| 248 | - Exceptions.deprecation("The CLR module is deprecated. Please use 'clr'."); | ||
| 249 | - } | ||
| 250 | 246 | IntPtr clr_module = GetCLRModule(fromList); | |
| 251 | 247 | if (clr_module != IntPtr.Zero) | |
| 252 | 248 | { | |
@@ -262,51 +258,41 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) | |||
| 262 | 258 | string realname = mod_name; | |
| 263 | 259 | string clr_prefix = null; | |
| 264 | 260 | ||
| 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) | ||
| 266 | 270 | { | |
| 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)) | ||
| 283 | 273 | { | |
| 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(); | ||
| 297 | 276 | } | |
| 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 | + } | ||
| 298 | 285 | ||
| 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; | ||
| 309 | 293 | } | |
| 294 | + // Otherwise, just clear the it. | ||
| 295 | + Exceptions.Clear(); | ||
| 310 | 296 | ||
| 311 | 297 | string[] names = realname.Split('.'); | |
| 312 | 298 | ||
@@ -372,7 +358,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) | |||
| 372 | 358 | // Add the module to sys.modules | |
| 373 | 359 | Runtime.PyDict_SetItemString(modules, tail.moduleName, tail.pyHandle); | |
| 374 | 360 | ||
| 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 | ||
| 376 | 362 | if (clr_prefix != null) | |
| 377 | 363 | { | |
| 378 | 364 | Runtime.PyDict_SetItemString(modules, clr_prefix + tail.moduleName, tail.pyHandle); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -492,7 +492,6 @@ private static void ClearClrModules() | |||
| 492 | 492 | private static void RemoveClrRootModule() | |
| 493 | 493 | { | |
| 494 | 494 | var modules = PyImport_GetModuleDict(); | |
| 495 | - PyDictTryDelItem(modules, "CLR"); | ||
| 496 | 495 | PyDictTryDelItem(modules, "clr"); | |
| 497 | 496 | PyDictTryDelItem(modules, "clr._extra"); | |
| 498 | 497 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,7 +176,7 @@ internal static IntPtr CreateType(Type impl) | |||
| 176 | 176 | internal static IntPtr CreateType(ManagedType impl, Type clrType) | |
| 177 | 177 | { | |
| 178 | 178 | // Cleanup the type name to get rid of funny nested type names. | |
| 179 | - string name = "CLR." + clrType.FullName; | ||
| 179 | + string name = $"clr.{clrType.FullName}"; | ||
| 180 | 180 | int i = name.LastIndexOf('+'); | |
| 181 | 181 | if (i > -1) | |
| 182 | 182 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,8 @@ public class ThreadTest | |||
| 11 | 11 | private static PyObject module; | |
| 12 | 12 | ||
| 13 | 13 | 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" + | ||
| 16 | 16 | "\n" + | |
| 17 | 17 | "def echostring(value):\n" + | |
| 18 | 18 | " return value\n" + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ def __init__(self): | |||
| 14 | 14 | @clr.clrmethod(int, [int]) | |
| 15 | 15 | def test(self, x): | |
| 16 | 16 | return x*2 | |
| 17 | - | ||
| 17 | + | ||
| 18 | 18 | def get_X(self): | |
| 19 | 19 | return self._x | |
| 20 | 20 | def set_X(self, value): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments