From: <pj...@us...> - 2009-10-20 01:16:03
|
Revision: 6880 http://jython.svn.sourceforge.net/jython/?rev=6880&view=rev Author: pjenvey Date: 2009-10-20 01:15:51 +0000 (Tue, 20 Oct 2009) Log Message: ----------- move the environ dict into the more appropriate PosixModule Modified Paths: -------------- trunk/jython/Lib/posix.py trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/modules/posix/PosixModule.java Modified: trunk/jython/Lib/posix.py =================================================================== --- trunk/jython/Lib/posix.py 2009-10-20 00:54:00 UTC (rev 6879) +++ trunk/jython/Lib/posix.py 2009-10-20 01:15:51 UTC (rev 6880) @@ -20,11 +20,11 @@ from org.python.core.Py import newString as asPyString __all__ = _posix.__all__[:] -__all__.extend(['_exit', 'access', 'chdir', 'chmod', 'close', 'environ', - 'fdopen', 'fsync', 'ftruncate', 'getcwd', 'getcwdu', 'getenv', - 'getpid', 'isatty', 'listdir', 'lseek', 'mkdir', 'open', - 'popen', 'putenv', 'read', 'remove', 'rename', 'rmdir', - 'system', 'umask', 'unlink', 'unsetenv', 'urandom', 'utime', +__all__.extend(['_exit', 'access', 'chdir', 'chmod', 'close', 'fdopen', + 'fsync', 'ftruncate', 'getcwd', 'getcwdu', 'getenv', 'getpid', + 'isatty', 'listdir', 'lseek', 'mkdir', 'open', 'popen', + 'putenv', 'read', 'remove', 'rename', 'rmdir', 'system', + 'umask', 'unlink', 'unsetenv', 'urandom', 'utime', 'write']) _name = _posix.__name__[1:] @@ -406,8 +406,6 @@ """ return java.lang.System.getProperty("user.name") -environ = sys.getEnviron() - def putenv(key, value): """putenv(key, value) Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-10-20 00:54:00 UTC (rev 6879) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-10-20 01:15:51 UTC (rev 6880) @@ -125,8 +125,6 @@ private String currentWorkingDir; - private PyObject environ; - private ClassLoader classLoader = null; public PyObject stdout, stderr, stdin; @@ -165,7 +163,6 @@ path_importer_cache = new PyDictionary(); currentWorkingDir = new File("").getAbsolutePath(); - initEnviron(); // Set up the initial standard ins and outs String mode = Options.unbuffered ? "b" : ""; @@ -437,27 +434,6 @@ } /** - * Initialize the environ dict from System.getenv. environ may be empty when the - * security policy doesn't grant us access. - */ - public void initEnviron() { - environ = new PyDictionary(); - Map<String, String> env; - try { - env = System.getenv(); - } catch (SecurityException se) { - return; - } - for (Map.Entry<String, String> entry : env.entrySet()) { - environ.__setitem__(Py.newString(entry.getKey()), Py.newString(entry.getValue())); - } - } - - public PyObject getEnviron() { - return environ; - } - - /** * Change the current working directory to the specified path. * * path is assumed to be absolute and canonical (via Modified: trunk/jython/src/org/python/modules/posix/PosixModule.java =================================================================== --- trunk/jython/src/org/python/modules/posix/PosixModule.java 2009-10-20 00:54:00 UTC (rev 6879) +++ trunk/jython/src/org/python/modules/posix/PosixModule.java 2009-10-20 01:15:51 UTC (rev 6880) @@ -4,12 +4,15 @@ import com.kenai.constantine.Constant; import com.kenai.constantine.platform.Errno; +import java.util.Map; + import org.jruby.ext.posix.JavaPOSIX; import org.jruby.ext.posix.POSIX; import org.jruby.ext.posix.POSIXFactory; import org.python.core.ClassDictInit; import org.python.core.Py; +import org.python.core.PyDictionary; import org.python.core.PyList; import org.python.core.PyObject; import org.python.core.PyString; @@ -60,6 +63,7 @@ // Successful termination dict.__setitem__("EX_OK", Py.Zero); + dict.__setitem__("environ", getEnviron()); dict.__setitem__("error", Py.OSError); dict.__setitem__("stat_result", PyStatResult.TYPE); dict.__setitem__("_posix_impl", Py.java2py(posix)); @@ -126,6 +130,24 @@ return new PyTuple(commandsTup); } + /** + * Initialize the environ dict from System.getenv. environ may be empty when the + * security policy doesn't grant us access. + */ + private static PyObject getEnviron() { + PyObject environ = new PyDictionary(); + Map<String, String> env; + try { + env = System.getenv(); + } catch (SecurityException se) { + return environ; + } + for (Map.Entry<String, String> entry : env.entrySet()) { + environ.__setitem__(Py.newString(entry.getKey()), Py.newString(entry.getValue())); + } + return environ; + } + public static POSIX getPOSIX() { return posix; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |