Python super() behavior not dependable

前端 未结 5 1740
逝去的感伤
逝去的感伤 2021-02-01 13:37

For some reason, the super() method is not always behaving as expected, opting to return:

TypeError(\'super(type, obj): obj must be an instance or          


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 14:30

    Are you reloading modules somehow in the middle of things? If so, that may explain this error.

    isinstance(self,DBAdminConnection) may become false after reloading modules because of the changes to memory references, apparently.

    Edit: if you're running your web.py app under mod_wsgi, make sure you're disabling autoreload:

    app = web.application(urls, globals(), autoreload=False)
    

提交回复
热议问题