summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-03-26 18:06:19 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-07-25 08:17:59 (GMT)
commitc028af586b9b24f79641c909046325f7ac06f59b (patch)
treedd3654ca76319964539c8c896a8c8a9d266822ef
parentd009b35ab2f2d6c7d5665e92c3fcba5e1a7cccda (diff)
downloadeopayment-c028af586b9b24f79641c909046325f7ac06f59b.zip
eopayment-c028af586b9b24f79641c909046325f7ac06f59b.tar.gz
eopayment-c028af586b9b24f79641c909046325f7ac06f59b.tar.bz2
common: add escape() method for python3
-rw-r--r--eopayment/common.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/eopayment/common.py b/eopayment/common.py
index a16efe5..258f856 100644
--- a/eopayment/common.py
+++ b/eopayment/common.py
@@ -2,11 +2,15 @@ import os.path
import os
import random
import logging
-import cgi
from datetime import date
import six
+if six.PY3:
+ import html
+else:
+ import cgi
+
__all__ = ['PaymentCommon', 'URL', 'HTML', 'RANDOM', 'RECEIVED', 'ACCEPTED',
'PAID', 'ERROR', 'WAITING']
@@ -162,7 +166,10 @@ class Form(object):
return s
def escape(self, s):
- return cgi.escape(force_text(s, self.encoding).encode(self.encoding))
+ if six.PY3:
+ return html.escape(force_text(s, self.encoding))
+ else:
+ return cgi.escape(force_text(s, self.encoding)).encode(self.encoding)
def __str__(self):
s = '<form method="%s" action="%s">' % (self.method, self.url)