Message211624
In fact, there is also a clearenv() function which could be used by os.environ.clear().
"The clearenv() function clears the environment of all name-value pairs and sets the value of the external variable environ to NULL."
It looks like supported names depends a lot on the platform and platform version. Extract of Linux manual pages:
setenv:
---
BUGS:
POSIX.1-2001 specifies that if name contains an '=' character, then setenv() should fail with the error EINVAL; however, versions of glibc before 2.3.4 allowed an '=' sign in name.
---
clearenv:
---
CONFORMING TO
Various UNIX variants (DG/UX, HP-UX, QNX, ...). POSIX.9 (bindings for FORTRAN77). POSIX.1-1996 did not accept clearenv() and putenv(3), but changed its mind and scheduled these functions for some later issue of this standard (cf. B.4.6.1). However, POSIX.1-2001 adds only putenv(3), and rejected clearenv().
---
> In any case I think we should wrap unsetenv() in os.environ.clear() so that it should try to remove all environment variables even if some calls of unsetenv() fails.
os.environ.clear() may tries to remove as much keys as possible, but keep keys for which unsetenv raised an error and raise a global error in this case. |
|
Date |
User |
Action |
Args |
2014-02-19 15:06:54 | vstinner | set | recipients:
+ vstinner, blueyed, ned.deily, serhiy.storchaka |
2014-02-19 15:06:54 | vstinner | set | messageid: <1392822414.5.0.313606569038.issue20658@psf.upfronthosting.co.za> |
2014-02-19 15:06:54 | vstinner | link | issue20658 messages |
2014-02-19 15:06:53 | vstinner | create | |
|