如何编辑CPython的Lib / importlib / _bootstrap.py?

时间:2019-07-06 10:39:41

标签: python compilation cpython python-importlib

我想使用CPython的Lib / importlib / _bootstrap.py文件,但是当我导入模块时,在MacOS上当前的CPython安装(与Homebrew软件包管理器一起安装)中所做的编辑无效。

例如,如果我在$ java -version java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode) $ sbt sbtVersion [info] Loading global plugins from C:\Users\hce\.sbt\1.0\plugins [info] Loading project definition from E:\learn\Scala\demo\foo-build\project [info] Loading settings for project foo-build from build.sbt ... [info] Set current project to foo-build (in build file:/E:/learn/Scala/demo/foo-build/) [info] 1.2.8 $ systeminfo.exe | grep '^OS' OS Name: Microsoft Windows 10 Enterprise LTSC OS Version: 10.0.17763 N/A Build 17763 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Workstation OS Build Type: Multiprocessor Free 函数主体的开头添加了print("hello")语句:

_init_module_attrs

然后导入一个模块:

$ vi /usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/_bootstrap.py

什么也没打印。

1 个答案:

答案 0 :(得分:0)

<hgroup> <img src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/cropped-45795044_561214090992995_7744636018275385344_n.jpg" class="header-image" width="25%" alt="sustainablewestonma"> <span class="span"> Educate ● Initiate ● Collaborate</span> </hgroup>是冻结的模块。要对其进行更新,应重新编译importlib._bootstrap模块:

importlib