[Bug 1166691] [NEW] "NameError: global name 're' is not defined" in ssl module

Stein Magnus Jodal stein.magnus at jodal.no
Tue Apr 9 09:43:33 UTC 2013


Public bug reported:

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

** Affects: python2.7 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python2.7 in Ubuntu.
https://bugs.launchpad.net/bugs/1166691

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

Status in “python2.7” package in Ubuntu:
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1166691/+subscriptions




More information about the foundations-bugs mailing list