[Python-checkins] python/dist/src/Lib getopt.py,1.21,1.22

Jack Jansen Jack.Jansen@oratrix.com
Mon, 29 Jul 2002 10:33:15 +0200


On Sunday, July 28, 2002, at 11:57 , Guido van Rossum wrote:
> Hm.  That sounds like a bug.  There's code in os.py like this:
>
> try:
>     putenv
> except NameError:
>     pass
> else:
>     ...Here os.environ is redefined so changes are propagated...
>
>     def getenv(key, default=None):
>         return environ.get(key, default)
>     __all__.append("getenv")
>
> If this doesn't define getenv for you, it must mean you don't have
> putenv?

Correct. The environment isn't going to go anywhere for MacPython, it's 
purely a convenience for use within Python, to forestall lots of special 
case code.

> It looks like the definition of getenv (which could be simplified to
> "getenv = environ.get" BTW) ought to be outside the try/except/else
> block.

Alternatively os.py could grow code like
if sys.platform == 'mac':
	def putenv(name, value):
		environ[name] = value


--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma 
Goldman -