[Python-Dev] Re: os module UserDict

Dietmar Schwertberger dietmar@schwertberger.de
Tue, 6 Mar 2001 23:54:30 +0100 (GMT)


Hi Martin,

thanks for CC'ing to me.

On Tue 06 Mar, Martin v. Loewis wrote:
> > I think that the problem is that the whole _Environ stuff should be
> > inside the else part of the try/except, but I'm not sure I fully
> > understand what goes on.  Could whoever did these mods have a look?
> 
> I agree that this patch was broken; the _Environ stuff was in the else
> part before. The change was committed by gvanrossum; the checkin
> comment says that its author was dschwertberger. 
Yes, it's from me. Unfortunately a whitespace problem with me, my editor
and my diffutils required Guido to apply most of the patches manually...


> > Also, it seems that the whole if name != "riscos" is a bit of a
> > hack...
> 
> I agree. What it seems to say is 'even though riscos does have a
> putenv, we cannot/should not/must not wrap environ with a UserDict.'
> 
> I'd suggest to back-out this part of the patch, unless a consistent
> story can be given RSN.
In plat-riscos there is a different UserDict-like implementation of
environ which is imported at the top of os.py in the 'riscos' part.
'name != "riscos"' just avoids overriding this. Maybe it would have
been better to include riscosenviron._Environ into os.py, as this would
look - and be - less hacky?
I must admit, I didn't care much when I started with riscosenviron.py
by just copying UserDict.py last year.

The RISC OS implementation doesn't store any data itself but just
emulates a dictionary with getenv() and putenv().
This is more suitable for the use of the environment under RISC OS, as
it is used quite heavily for a lot of configuration data and may grow
to some hundred k quite easily. So it is undesirable to import all the
data at startup if it is not required really.
Also the environment is being used for communication between tasks
sometimes (the changes don't just affect subprocesses started later,
but all tasks) and so read access to environ should return the current
value.


And this is just _one_ of the points where RISC OS is different from
the rest of the world...


> Regards,
> Martin
> 
> P.S. os.py mentions an "import riscos". Where is that module?
riscosmodule.c lives in the RISCOS subdirectory together with all the
other RISC OS specific stuff needed for building the binaries.


Regards,

Dietmar

P.S.: How can I subscribe to python-dev (at least read-only)?
      I couldn't find a reference on python.org or Sourceforge.
P.P.S.: If you wonder what RISC OS is and why it is different:
        You may remember the 'Archimedes' from the british
        manufacturer Acorn. This was the first RISC OS computer...