File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1386,6 +1386,21 @@ Removed
1386
1386
``imp.source_from_cache() `` :func: `importlib.util.source_from_cache `
1387
1387
================================= =======================================
1388
1388
1389
+ * Replace ``imp.load_source() `` with::
1390
+
1391
+ import importlib.util
1392
+ import importlib.machinery
1393
+
1394
+ def load_source(modname, filename):
1395
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
1396
+ spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
1397
+ module = importlib.util.module_from_spec(spec)
1398
+ # The module is always executed and not cached in sys.modules.
1399
+ # Uncomment the following line to cache the module.
1400
+ # sys.modules[module.__name__] = module
1401
+ loader.exec_module(module)
1402
+ return module
1403
+
1389
1404
* Removed :mod: `!imp ` functions and attributes with no replacements:
1390
1405
1391
1406
* undocumented functions:
@@ -1394,7 +1409,6 @@ Removed
1394
1409
* ``imp.load_compiled() ``
1395
1410
* ``imp.load_dynamic() ``
1396
1411
* ``imp.load_package() ``
1397
- * ``imp.load_source() ``
1398
1412
1399
1413
* ``imp.lock_held() ``, ``imp.acquire_lock() ``, ``imp.release_lock() ``:
1400
1414
the locking scheme has changed in Python 3.3 to per-module locks.
You can’t perform that action at this time.
0 commit comments