New submission from hansokumake <hansokum...@seznam.cz>: I tried this example from the documentation:
from html.parser import HTMLParser class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Encountered a start tag:", tag) def handle_endtag(self, tag): print("Encountered an end tag :", tag) def handle_data(self, data): print("Encountered some data :", data) parser = MyHTMLParser(strict=False) parser.feed('<html><head><title>Test</title></head>' '<body><h1>Parse me!</h1></body></html>') According to documentation the output should be like this: Encountered a start tag: html Encountered a start tag: head Encountered a start tag: title Encountered some data : Test Encountered an end tag : title Encountered an end tag : head Encountered a start tag: body Encountered a start tag: h1 Encountered some data : Parse me! Encountered an end tag : h1 Encountered an end tag : body Encountered an end tag : html but Python produced this: Encountered some data : <html> Encountered some data : <head> Encountered some data : <title> Encountered some data : Test Encountered an end tag : title Encountered an end tag : head Encountered some data : <body> Encountered some data : <h1> Encountered some data : Parse me! Encountered an end tag : h1 Encountered an end tag : body Encountered an end tag : html If strict is set to True, it works correctly. ---------- assignee: docs@python components: Documentation messages: 163318 nosy: docs@python, hansokumake priority: normal severity: normal status: open title: Different behavior of html.parser.HTMLParser type: behavior versions: Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15120> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com