Python 3.4 DeprecationWarning convert_charrefs

假如想象 提交于 2021-01-28 10:10:46

问题


Using UnitTest in the shell:

python3.4 -m unittest my_test.py -v

I get the DeprecationWarning

DeprecationWarning: The value of convert_charrefs will become True in 3.5. You are encouraged to set the value explicitly.  super().__init__() ERROR

So it seems

super().__init__()

triggers this DeprecationWarning. But I can not find anything about convert_charrefs warning. Also the used statement is used in the Python documentation, and multiple examples in SO.

What causes this warning, and how can I solve this? Thanks.


回答1:


convert_charrefs correspond to HTMLParser. If you inherit from this class you must explicitly specify convert_charrefs:

class Foo(HTMLParser): 
  def __init__(self): 
    super().__init__(convert_charrefs=True)


来源:https://stackoverflow.com/questions/48203228/python-3-4-deprecationwarning-convert-charrefs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!