Index: Lib/sgmllib.py =================================================================== --- Lib/sgmllib.py (revision 70847) +++ Lib/sgmllib.py (working copy) @@ -396,7 +396,7 @@ n = int(name) except ValueError: return - if not 0 <= n <= 255: + if not 0 <= n <= 127: return return self.convert_codepoint(n) Index: Lib/test/test_sgmllib.py =================================================================== --- Lib/test/test_sgmllib.py (revision 70847) +++ Lib/test/test_sgmllib.py (working copy) @@ -373,6 +373,13 @@ if len(data) != CHUNK: break + def test_only_decode_ascii(self): + # SF bug #1651995, make sure non-ascii character references are not decoded + s = '' + self.check_events(s, [ + ('starttag', 'signs', [('exclamation', '!'), ('copyright', '©'), ('quoteleft', '‘')]), + ]) + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior