"NameError: global name 're' is not defined" in ssl module

Bug #1166691 reported by Stein Magnus Jodal
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python2.7 (Ubuntu)
Confirmed
High
Unassigned

Bug Description

After the upgrade from python2.7 2.7.4~rc1-4ubuntu1 to 2.7.4-1ubuntu2 today, pip (latest release, 1.3.1, installed from PyPI) stopped working due to a "re" import missing in the "ssl" module in Python's standard library.

A small example to reproduce the crash:

$ python
Python 2.7.4 (default, Apr 8 2013, 21:29:38)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.__file__
'/usr/lib/python2.7/ssl.pyc'
>>> ssl._dnsname_to_pat('')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/ssl.py", line 111, in _dnsname_to_pat
    frag = re.escape(frag)
NameError: global name 're' is not defined
>>>

Full output from pip:

$ pip --version
pip 1.3.1 from /usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg (python 2.7)
$ sudo pip install -U pip
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/basecommand.py", line 139, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/commands/install.py", line 266, in r
un
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/req.py", line 960, in prepare_files
    req_to_install, self.upgrade)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 125, in find_require
ment
    page = self._get_page(main_index_url, req)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 353, in _get_page
    return HTMLPage.get_page(link, req, cache=self.cache)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/index.py", line 471, in get_page
    resp = urlopen(url)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/download.py", line 143, in __call__
    response = self.get_opener(scheme=scheme).open(url)
  File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/download.py", line 123, in https_ope
n
    return self.do_open(self.specialized_conn_class, req)
  File "/usr/lib/python2.7/urllib2.py", line 1181, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/lib/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 791, in send
    self.connect()
  File "/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg/pip/download.py", line 107, in connect
    match_hostname(self.sock.getpeercert(), self.host)
  File "/usr/lib/python2.7/ssl.py", line 130, in match_hostname
    if _dnsname_to_pat(value).match(hostname):
  File "/usr/lib/python2.7/ssl.py", line 111, in _dnsname_to_pat
    frag = re.escape(frag)
NameError: global name 're' is not defined
Storing complete log in /home/jodal/.pip/pip.log

Revision history for this message
Stein Magnus Jodal (jodal) wrote :
Changed in python2.7 (Ubuntu):
importance: Undecided → High
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.