# HG changeset patch
# User Jean-Francois Pieronne <jf.pieronne@laposte.net>
# Date 1598254229 -34200
#      Mon Aug 24 17:00:29 2020 +0930
# Node ID af3c84545f5923b971cc7ca11c7cd04bd4b0074c
# Parent  a7f4905f74b5b93d08300c55359ac4c1e05b3706
v1.1.3 update

diff --git a/src/python/build_pyrte.com b/src/python/build_pyrte.com
--- a/src/python/build_pyrte.com
+++ b/src/python/build_pyrte.com
@@ -1,7 +1,7 @@
 $!-----------------------------------------------------------------------------
 $! BUILD_PYRTE.COM
 $!
-$! Copyright (C) 2007 Mark G.Daniel.
+$! Copyright (C) 2007-2009 Mark G.Daniel.
 $! This package (all associated programs), comes with ABSOLUTELY NO WARRANTY.
 $! This is free software, and you are welcome to redistribute it
 $! under the conditions of the GNU GENERAL PUBLIC LICENSE, version 2.
@@ -10,7 +10,7 @@
 $! VERSION HISTORY
 $! ---------------
 $!
-$ IMAGE_IDENT = "PYRTE100"
+$ IMAGE_IDENT = "PYRTE113"
 $!
 $! 22-APR-2007  JFP  use same build options as Python
 $! 10-APR-2007  MGD  initial
diff --git a/src/python/pyrte.c b/src/python/pyrte.c
--- a/src/python/pyrte.c
+++ b/src/python/pyrte.c
@@ -187,7 +187,7 @@
 
 PYRTE COPYRIGHT
 ---------------
-Copyright (C) 2007,2008 Mark G.Daniel
+Copyright (C) 2007-2009 Mark G.Daniel
 This package comes with ABSOLUTELY NO WARRANTY.
 This is free software, and you are welcome to redistribute it under the
 conditions of the GNU GENERAL PUBLIC LICENSE, version 3, or any later version.
@@ -271,6 +271,7 @@
 
 VERSION HISTORY (update SOFTWAREVN as well!)
 ---------------
+07-DEC-2009  JFP  v1.1.3, os.environ is not a dictionary on OpenVMS
 19-APR-2008  JFP  v1.1.2, WSGI buffered output (see description above)
 17-JAN-2008  MGD  v1.1.1, CgiVar() and CgiVarDclSymbol() ensure an empty
                             SCRIPT_NAME *is* empty (not the WASD-ism "/")
@@ -279,8 +280,8 @@
 */
 /*****************************************************************************/
 
-#define SOFTWARECR "Copyright (C) 2007,2008 Mark G.Daniel"
-#define SOFTWAREVN "1.1.2"
+#define SOFTWARECR "Copyright (C) 2007-2009 Mark G.Daniel"
+#define SOFTWAREVN "1.1.3"
 #define SOFTWARENM "PYRTE"
 #ifdef __ALPHA
 #  define SOFTWAREID SOFTWARENM " AXP-" SOFTWAREVN
@@ -1552,7 +1553,8 @@
    int  retval;
    char  *cptr, *sptr,
          *NamePtr;
-   PyObject  *pValue;
+   PyObject  *pValue, *pKey, *pKeys;
+   Py_ssize_t  pKenLen;
 
    /*********/
    /* begin */
@@ -1578,14 +1580,30 @@
       if (!pEnvironDict)
       {
          /* new reference */
-         pEnvironDict = PyDict_New ();
+         pEnvironDict = PyObject_CallMethod(pOsEnvironDict, "copy", "()");
       }
-
-      retval = PyDict_Merge (pEnvironDict, pOsEnvironDict, 0);
-      if (retval)
-      {
-         ReportError (__LINE__, 0, 1, ErrorCgiVarEnv);
-         return (0);
+      else
+      {      
+          /* Restore missing environ variables */
+          pKeys = PyMapping_Keys(pOsEnvironDict);
+          pKenLen = PyList_Size(pKeys);
+          for (int i = 0; i < pKenLen; ++i)
+          {
+              pKey = PyList_GetItem(pKeys, i);
+              if (! PyMapping_HasKey(pEnvironDict, pKey))
+              {
+                  char *key;
+                  key = PyString_AsString(pKey);
+                  pValue = PyMapping_GetItemString(pOsEnvironDict, key);
+                  retval = PyMapping_SetItemString(pEnvironDict, key, pValue);
+                  if (retval = -1)
+                  {
+                      ReportError (__LINE__, 0, 1, ErrorCgiVarEnv);
+                      return (0);
+                  }
+              }
+          }
+          Py_DECREF(pKeys);
       }
       DEBUGPYOBJ("pEnvironDict",pEnvironDict)
 
@@ -1610,7 +1628,7 @@
          if (!*sptr) continue;
          *sptr = '\0';
          pValue = PyString_FromString (sptr+1);
-         retval = PyDict_SetItemString (pEnvironDict, cptr, pValue);
+         retval = PyMapping_SetItemString (pEnvironDict, cptr, pValue);
          Py_DECREF (pValue);
          *sptr = '=';
       }
@@ -1622,7 +1640,7 @@
    else
    {
       DEBUGPYOBJ("1pEnvironDict",pEnvironDict)
-      PyDict_Clear (pEnvironDict);
+      PyObject_CallMethod(pOsEnvironDict, "clear", "()");
       DEBUGPYOBJ("2pEnvironDict",pEnvironDict)
    }
 
diff --git a/src/python/readme.txt b/src/python/readme.txt
--- a/src/python/readme.txt
+++ b/src/python/readme.txt
@@ -4,7 +4,7 @@
 
 PYRTE COPYRIGHT
 ---------------
-Copyright (C) 2007,2008 Mark G.Daniel
+Copyright (C) 2007-2009 Mark G.Daniel
 This package comes with ABSOLUTELY NO WARRANTY.
 This is free software, and you are welcome to redistribute it under the
 conditions of the GNU GENERAL PUBLIC LICENSE, version 3, or any later version.
diff --git a/src/python/readmore.html b/src/python/readmore.html
--- a/src/python/readmore.html
+++ b/src/python/readmore.html
@@ -60,9 +60,9 @@
 <CENTER>
 
 <H1>Python Run-Time Environment</H1>
-<H3>Version 1.1.2, 19th April 2008</H3>
+<H3>Version 1.1.3, 7th Decmeber 2009</H3>
 
-<P><B>Copyright &copy; 2007,2008 Mark G. Daniel</B>
+<P><B>Copyright &copy; 2007-2009 Mark G. Daniel</B>
 <BR>This program, comes with ABSOLUTELY NO WARRANTY.
 <BR>This is free software, and you are welcome to redistribute it under the
 <BR>conditions of the GNU GENERAL PUBLIC LICENSE, version 3, or any later version.