kmonsoor / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Fix deprecation warning in Python 3.4 #741

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I get these warnings when using HTMLDecoder:

/home/larsoner/.local/lib/python3.4/site-packages/pyglet/text/__init__.py:144: 
DeprecationWarning: The value of convert_charrefs will become True in 3.5. You 
are encouraged to set the value explicitly.
  return html.HTMLDecoder()

This change initializes the super classes, expliciting setting 
"convert_charrefs=True" as recommended by the warning:

https://code.google.com/r/larsonericd-clone/source/detail?r=f4fd5f054e87508ed183
7b839afa3df82c1579b7&name=fixpulse

Original issue reported on code.google.com by larson.e...@gmail.com on 7 May 2014 at 6:23

GoogleCodeExporter commented 9 years ago

Original comment by useboxnet on 8 May 2014 at 5:59

GoogleCodeExporter commented 9 years ago
I'm not sure about this patch, HTMLParser.__Init__ doesn't have parameters in 
python 2.

Original comment by useboxnet on 16 Jul 2014 at 5:18

GoogleCodeExporter commented 9 years ago
I started looking into using `inspect.getargspec`, but on py3k we'd need to use 
`inspect.getfullargspec` which doesn't exist on python2...

It should work just to triage based on `sys.version[0] == '3'`. WDYT?

Original comment by larson.e...@gmail.com on 16 Jul 2014 at 5:26

GoogleCodeExporter commented 9 years ago
Well, we have this module already:

https://code.google.com/p/pyglet/source/browse/pyglet/compat.py

Original comment by useboxnet on 16 Jul 2014 at 6:10

GoogleCodeExporter commented 9 years ago
One solution would then be to wrap it like this for Python3:

HTMLParser_init = partial(HTMLParser.HTMLParser.__init__, convert_charrefs=True)

and for Python2:

HTMLParser_init = HTMLParser.HTMLParser.__init__

And then have `pyglet.text.formats` import it from `compat.py`.

Original comment by larson.e...@gmail.com on 16 Jul 2014 at 6:17

GoogleCodeExporter commented 9 years ago
Sounds OK. I don't have a strong opinion besides using the compat module :)

Thanks!

Original comment by useboxnet on 16 Jul 2014 at 6:29