[Bug 1281086] Re: Crash in os.environ.clear() with empty environment key

Bug Watch Updater 1281086 at bugs.launchpad.net
Mon Feb 17 13:45:10 UTC 2014


** Changed in: python
       Status: Unknown => 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/1281086

Title:
  Crash in os.environ.clear() with empty environment key

Status in Python:
  New
Status in “apport” package in Ubuntu:
  New
Status in “python2.7” package in Ubuntu:
  New
Status in “python3.3” package in Ubuntu:
  New

Bug description:
  % ubuntu-bug apport
  Traceback (most recent call last):
    File "/usr/share/apport/apport-gtk", line 590, in <module>
      app.run_argv()
    File "/usr/lib/python3/dist-packages/apport/ui.py", line 654, in run_argv
      return self.run_report_bug()
    File "/usr/lib/python3/dist-packages/apport/ui.py", line 456, in run_report_bug
      self.collect_info(symptom_script)
    File "/usr/lib/python3/dist-packages/apport/ui.py", line 1031, in collect_info
      os.environ.clear()
    File "/usr/lib/python3.3/collections/abc.py", line 553, in clear
      self.popitem()
    File "/usr/lib/python3.3/collections/abc.py", line 546, in popitem
      del self[key]
    File "/usr/lib/python3.3/os.py", line 687, in __delitem__
      self.unsetenv(encodedkey)
  OSError: [Errno 22] Invalid argument

  Looking at the output of `os.environ`, there is a odd entry (key '').

  os.environ.clear() fails both with python2.7 and python3:

  In [1]: import os

  In [2]: os.environ[''] = ''

  In [3]: os.environ.clear()
  ---------------------------------------------------------------------------
  OSError                                   Traceback (most recent call last)
  <ipython-input-3-bfe7fb2930ac> in <module>()
  ----> 1 os.environ.clear()

  /usr/lib/python3.3/collections/abc.py in clear(self)
      551         try:
      552             while True:
  --> 553                 self.popitem()
      554         except KeyError:
      555             pass

  /usr/lib/python3.3/collections/abc.py in popitem(self)
      544             raise KeyError
      545         value = self[key]
  --> 546         del self[key]
      547         return key, value
      548 

  /usr/lib/python3.3/os.py in __delitem__(self, key)
      685     def __delitem__(self, key):
      686         encodedkey = self.encodekey(key)
  --> 687         self.unsetenv(encodedkey)
      688         try:
      689             del self._data[encodedkey]

  OSError: [Errno 22] Invalid argument

  While this looks like a bug to be fixed in Python also, apport should
  handle it gracefully, and not crash/abort on it.

  ProblemType: Bug
  DistroRelease: Ubuntu 13.10
  Package: apport 2.12.5-0ubuntu2.2
  ProcVersionSignature: Ubuntu 3.11.0-15.25-generic 3.11.10
  Uname: Linux 3.11.0-15-generic x86_64
  ApportVersion: 2.12.5-0ubuntu2.2
  Architecture: amd64
  CrashReports:
   640:1000:114:120104180:2014-02-13 00:58:41.677010970 +0100:2014-02-13 00:57:20.989009053 +0100:/var/crash/_opt_firefox_firefox.1000.crash
   640:1000:114:63870076:2014-02-13 00:00:35.972928127 +0100:2014-02-12 23:59:49.260927017 +0100:/var/crash/_usr_lib_firefox_firefox.1000.crash
   640:1000:114:14175879:2014-02-09 10:23:03.104148831 +0100:2014-02-09 10:22:57.576148699 +0100:/var/crash/_usr_bin_nautilus.1000.crash
  Date: Mon Feb 17 13:41:48 2014
  InstallationDate: Installed on 2012-05-28 (629 days ago)
  InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
  MarkForUpload: True
  PackageArchitecture: all
  SourcePackage: apport
  UpgradeStatus: Upgraded to saucy on 2013-10-08 (131 days ago)
  modified.conffile..etc.default.apport: [modified]
  mtime.conffile..etc.default.apport: 2014-02-13T00:58:07.609010

To manage notifications about this bug go to:
https://bugs.launchpad.net/python/+bug/1281086/+subscriptions



More information about the foundations-bugs mailing list