src/reportlab/platypus/paraparser.py
branchpy33
changeset 3994 9c38aba205e1
parent 3961 8c5743bc6489
child 4004 ebd460ef8d2f
--- a/src/reportlab/platypus/paraparser.py	Sat Jan 11 19:56:27 2014 +0000
+++ b/src/reportlab/platypus/paraparser.py	Mon Jan 13 15:36:56 2014 +0000
@@ -19,7 +19,7 @@
 import reportlab.lib.sequencer
 
 from reportlab.lib.abag import ABag
-from reportlab.lib.utils import ImageReader, isPy3, annotateException, encode_label, asUnicode, UniChr
+from reportlab.lib.utils import ImageReader, isPy3, annotateException, encode_label, asUnicode, asBytes, UniChr
 from reportlab.lib.colors import toColor, white, black, red, Color
 from reportlab.lib.fonts import tt2ps, ps2tt
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
@@ -493,6 +493,11 @@
 for k in greeks:
     if k not in known_entities:
         known_entities[k] = greeks[k]
+f = isPy3 and asBytes or asUnicode
+K = list(known_entities.keys())
+for k in K:
+    known_entities[f(k)] = known_entities[k]
+del k, f, K
 
 #------------------------------------------------------------------------
 class ParaFrag(ABag):
@@ -1178,9 +1183,9 @@
     def handle_entityref(self, name):
         "Handles a named entity.  "
         try:
-            v = UniChr(known_entities[name])
+            v = known_entities[name]
         except:
-            v = u'&%s;' % name
+            v = u'&%s;' % name
         self.handle_data(v)
 
 if __name__=='__main__':