[issue15120] Different behavior of html.parser.HTMLParser

2012-06-21 Thread hansokumake

New submission from hansokumake :

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('Test'
'Parse me!')



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  : 
Encountered some data  : 
Encountered some data  : 
Encountered some data  : Test
Encountered an end tag : title
Encountered an end tag : head
Encountered some data  : 
Encountered some data  : 
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 
<http://bugs.python.org/issue15120>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15120] Different behavior of html.parser.HTMLParser

2012-06-21 Thread hansokumake

hansokumake  added the comment:

I'm sorry. It's my fault. I still use Python 3.2.2.

--
status: open -> closed

___
Python tracker 
<http://bugs.python.org/issue15120>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com