Something strange with python 2.2.1 under RedHat 8.0

Discussion in 'Python' started by Richard Kuhns, Jun 26, 2003.

  1. I can't iterate over os.environ, while a 'hand-made' dictionary works. It
    works fine with python 2.2.3 under FreeBSD 4.8. I looked through the
    release notes but didn't find anything I thought applied, so I guess I'd
    just like to know if this is something peculiar to my system, or is it
    more wide-spread? Here's what I get:

    : molin$~; python
    Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
    [GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> for k in os.environ:

    .... print k
    ....
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    def __getitem__(self, key): return self.data[key]
    KeyError: 0
    >>> d = {}
    >>> d['one'] = 1
    >>> d['two'] = 2
    >>> d['three'] = 3
    >>> for k in d:

    .... print k
    ....
    three
    two
    one
    >>>


    --
    Richard Kuhns
    Richard Kuhns, Jun 26, 2003
    #1
    1. Advertising

  2. Richard Kuhns

    Peter Hansen Guest

    Richard Kuhns wrote:
    >
    > Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
    > [GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
    > Type "help", "copyright", "credits" or "license" for more information.
    > >>> import os
    > >>> for k in os.environ:

    > ... print k
    > ...
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
    > def __getitem__(self, key): return self.data[key]
    > KeyError: 0


    Judging by the error message, os.environ is *not* a dict, but
    a UserDict. If it were to be subclassed from IterableUserDict
    instead, it would work okay I guess.

    Checking Python 2.2.2, I find it *is* now subclassed from
    IterableUserDict, so you're reporting a bug that is fixed
    in a later release. Please upgrade.

    I'd check the bug tracker on SourceForge, but I am rarely able to use
    that pathetic piece of crap successfully to search for already-reported
    bugs, so I'll just skip it... :)

    -Peter
    Peter Hansen, Jun 26, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christoph Breidert
    Replies:
    6
    Views:
    730
    Chris Smith
    Feb 11, 2004
  2. Private
    Replies:
    2
    Views:
    486
    Michael Borgwardt
    Dec 11, 2004
  3. U. George
    Replies:
    4
    Views:
    823
    U. George
    Aug 11, 2005
  4. David Garamond
    Replies:
    3
    Views:
    84
  5. marmot101
    Replies:
    5
    Views:
    138
    Akop Pogosian
    Jul 29, 2003
Loading...

Share This Page