Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Something strange with python 2.2.1 under RedHat 8.0

Reply
Thread Tools

Something strange with python 2.2.1 under RedHat 8.0

 
 
Richard Kuhns
Guest
Posts: n/a
 
      06-26-2003
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 http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      06-26-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone try this on RedHat Linux/jre1.5 or redhat linux/jdk1.6? U. George Java 4 08-11-2005 12:33 PM
Difference in int cast to char between Windows and redhat linux 9 under JDK 1.4.2_06 Private Java 2 12-11-2004 01:30 AM
java 1.4.2_03 under redhat 9.0 - encoding problem Christoph Breidert Java 6 02-11-2004 02:58 PM
pl-ruby detecting postgresql 7.4 under redhat David Garamond Ruby 3 02-09-2004 09:42 AM
SNMP Config under RedHat 8.0 Behnam Cisco 0 08-01-2003 08:33 PM



Advertisments