This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients chris.jerdonek
Date 2012-04-11.05:26:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334121971.71.0.628267633735.issue14545@psf.upfronthosting.co.za>
In-reply-to
Content
The Python documentation says that the html module (defining html.escape()) is new in Python 3.2:

http://docs.python.org/dev/library/html.html

However, it's importable in Python 3.1, but without the escape() function.   See below for evidence.

This prevents the usual EAFP code from not working:

try:
    # Python 3.2 deprecates cgi.escape() and adds the html module as a replacement.
    import html
except ImportError:
    import cgi as html


> python
Python 3.1.4 (default, Apr 10 2012, 21:58:25) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import html
>>> html.escape
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'escape'
>>> dir(html)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> html.__file__
'/opt/local/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/html/__init__.py'
History
Date User Action Args
2012-04-11 05:26:11chris.jerdoneksetrecipients: + chris.jerdonek
2012-04-11 05:26:11chris.jerdoneksetmessageid: <1334121971.71.0.628267633735.issue14545@psf.upfronthosting.co.za>
2012-04-11 05:26:11chris.jerdoneklinkissue14545 messages
2012-04-11 05:26:10chris.jerdonekcreate