HTTP GET Explodes...
John Machin
sjmachin at lexicon.net
Sat Sep 23 21:16:13 EDT 2006
Pete wrote:
> I was running the HTTP GET example at
> http://www.python.org/doc/current/lib/httplib-examples.html and ran
> into a bit of trouble...
>
> >>> import httplib # This works.
> >>> conn = httplib.HTTPConnection("www.python.org") # This works.
> >>> conn.request("GET", "/index.html") # This does not work...
>
> The errors I get are below. Any suggestions on how to get rid of the
> errors? Thanks!
You have *ONE* error, with a long traceback, which is incomplete,
because it doesn't show the error message that should be at the end of
the traceback.
>
> # Begin errors...
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/httplib.py", line 801, in request
> self._send_request(method, url, body, headers)
> File "/usr/lib/python2.4/httplib.py", line 818, in _send_request
> self.putrequest(method, url, **skips)
> File "/usr/lib/python2.4/httplib.py", line 749, in putrequest
> self.putheader('Host', self.host.encode("idna"))
> File "/usr/lib/python2.4/encodings/__init__.py", line 96, in
> search_function
> globals(), locals(), _import_tail)
> File "/usr/lib/python2.4/encodings/idna.py", line 6, in ?
> dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
This is compiling a *constant* regular expression, and works OK on the
Windows distribution of Python 2.4.3 :
| Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
on win32
| Type "help", "copyright", "credits" or "license" for more
information.
| >>> import re
| >>> dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
| >>> dots.match('.')
| <_sre.SRE_Match object at 0x00AF6058> # bonus: compiled regex works.
| >>> dots.match(u'\uff61')
| <_sre.SRE_Match object at 0x00AF6918>
You appear to be running 2.4.n; what is n, and exactly which *x
platform are you running it on? Perhaps a file in /usr/lib/python2.4 is
corrupt, but we won't know until you give the *full* traceback. Do you
get the same results when you try what I did at the interpreter
interactive prompt?
> File "/usr/lib/python2.4/sre.py", line 180, in compile
> return _compile(pattern, flags)
> File "/usr/lib/python2.4/sre.py", line 225, in _compile
> p = sre_compile.compile(pattern, flags)
> File "/usr/lib/python2.4/sre_compile.py", line 500, in compile
> code = _code(p, flags)
> File "/usr/lib/python2.4/sre_compile.py", line 481, in _code
> _compile_info(code, p, flags)
> File "/usr/lib/python2.4/sre_compile.py", line 459, in _compile_info
> _compile_charset(charset, flags, code)
> File "/usr/lib/python2.4/sre_compile.py", line 178, in
> _compile_charset
> for op, av in _optimize_charset(charset, fixup):
> File "/usr/lib/python2.4/sre_compile.py", line 221, in
> _optimize_charset
> return _optimize_unicode(charset, fixup)
> File "/usr/lib/python2.4/sre_compile.py", line 341, in
> _optimize_unicode
> mapping = array.array('b', mapping).tostring()
... to be continued in the next episode.
Regards,
John
More information about the Python-list
mailing list