因为1个异常导入190个包
33 views | without comments
今天reddit programming上的一个帖子,提到了ubuntu上python-apport包的一个bug。
重现这个bug很简单:
Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> len(sys.modules) 35 >>> foo Traceback (most recent call last): File "", line 1, in NameError: name 'foo' is not defined >>> len(sys.modules) 225 >>>
在执行foo之前,当前导入的包只有35个,执行之后却有了225个。问题出在Ubuntu的Apport系统,它为Python添加了一个异常处理方法,这里面的bug导致了这些多余的包被导入。
这个bug已经被人提交并被确认,目前暂时还没有补丁,最简单的避免方法就是把python-apport包卸载
原文地址: http://rhodesmill.org/brandon/2010/ubuntu-exception-190-modules/