Skip to content

Commit f687414

Browse files
committed
python 3.9 compatibity unescape workaround
1 parent 4ae38f1 commit f687414

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cbmpy/CBXML.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
except:
4545
from html import escape as ESCAPE
4646

47+
try:
48+
from cgi import escape as ESCAPE
49+
except:
50+
from html import escape as ESCAPE
4751

4852
# this is a hack that needs to be streamlined a bit
4953
try:
@@ -62,7 +66,6 @@
6266

6367
HTMLParser = parser.HTMLParser
6468

65-
6669
from . import CBModel
6770
from .CBCommon import (
6871
getGPRasDictFromString,
@@ -261,8 +264,13 @@ def get_data(self):
261264
self.fed = []
262265
return data
263266

264-
267+
# with Python 3.9+ moving unescape we now need to implement a nasty hack
265268
__tagStripper__ = MLStripper()
269+
try:
270+
__tagStripper__.unescape('dfsdfsdfsdfsdfsdfsdef')
271+
except AttributeError as err:
272+
from html import unescape
273+
__tagStripper__.unescape = unescape
266274

267275

268276
def xml_stripTags(html):

0 commit comments

Comments
 (0)