diff genshi/util.py @ 859:f3d998cc941e trunk

More bits of 2to3 related cleanup.
author cmlenz
date Thu, 12 Nov 2009 17:01:52 +0000
parents 129e54866a98
children fc83430f6053
line wrap: on
line diff
--- a/genshi/util.py
+++ b/genshi/util.py
@@ -13,10 +13,7 @@
 
 """Various utility classes and functions."""
 
-try:
-    import htmlentitydefs as entities
-except ImportError:
-    from html import entities
+import htmlentitydefs as entities
 import re
 
 __docformat__ = 'restructuredtext en'
@@ -251,12 +248,11 @@
 
 
 def stringrepr(string):
-    slen = len(string)
     ascii = string.encode('ascii', 'backslashreplace')
-    r = "'" +  ascii.replace("'", "\\'") + "'"
-    if (unicode is not str) and (len(ascii) > len(string)):
-        return 'u' + r
-    return r
+    quoted = "'" +  ascii.replace("'", "\\'") + "'"
+    if len(ascii) > len(string):
+        return 'u' + quoted
+    return quoted
 
 
 # Compatibility fallback implementations for older Python versions
Copyright (C) 2012-2017 Edgewall Software