最简代码大致如下。
============= aabbcc.py ===========
class A(object):
def __init__(self):
print("A")
class B(A):
def __init__(self):
A.__init__()
print("B")
=============== ddeeff.py =============
import aabbcc
from aabbcc import A as OrigA
class MyA(OrigA):
def __init__(self):
super(MyA, self).__init__()
print("MyA")
aabbcc.A = MyA
b = B() # 此时报错如下
====
TypeError: unbound method __init__() must be called with MyA instance as fir
st argument (got nothing instead)
====
假设aabbcc.py文件不能改,请教如何写ddeeff.py可以让b=B()顺利通过呢?(功能上保
证hotpatch的MyA和原始的A是完全一致的)
--
修改:CKevin FROM 220.243.191.*
FROM 220.243.191.*