[Jython-checkins] jython (merge default -> default): Merge with trunk.

frank.wierzbicki jython-checkins at python.org
Wed May 18 02:53:30 CEST 2011


http://hg.python.org/jython/rev/afae29255c2c
changeset:   6213:afae29255c2c
parent:      6212:67f89e017e31
parent:      6209:54ab8647cb83
user:        Frank Wierzbicki <fwierzbicki at gmail.com>
date:        Thu May 12 23:24:52 2011 -0700
summary:
  Merge with trunk.

files:
  src/org/python/core/Options.java       |  5 ++++-
  src/org/python/core/PySystemState.java |  4 ++++
  src/org/python/core/imp.java           |  4 +++-
  src/org/python/util/jython.java        |  4 +++-
  4 files changed, 14 insertions(+), 3 deletions(-)


diff --git a/src/org/python/core/Options.java b/src/org/python/core/Options.java
--- a/src/org/python/core/Options.java
+++ b/src/org/python/core/Options.java
@@ -76,9 +76,12 @@
      * binary mode */
     public static boolean unbuffered = false;
 
-    /** Whether -3 (py3k warnings) were enabled via the command line. */
+    /** Whether -3 (py3k warnings) was enabled via the command line. */
     public static boolean py3kwarning = false;
     
+    /** Whether -B (don't write bytecode on import) was enabled via the command line. */
+    public static boolean dontWriteBytecode = false;
+
     //XXX: place holder
     public static int bytes_warning = 0;
 
diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java
--- a/src/org/python/core/PySystemState.java
+++ b/src/org/python/core/PySystemState.java
@@ -162,6 +162,9 @@
     /** true when a SystemRestart is triggered. */
     public boolean _systemRestart = false;
 
+    /** Whether bytecode should be written to disk on import. */
+    public boolean dont_write_bytecode = false;
+
     // Automatically close resources associated with a PySystemState when they get GCed
     private final PySystemStateCloser closer;
     private static final ReferenceQueue<PySystemState> systemStateQueue =
@@ -189,6 +192,7 @@
 
         currentWorkingDir = new File("").getAbsolutePath();
 
+        dont_write_bytecode = Options.dontWriteBytecode;
         py3kwarning = Options.py3kwarning;
         // Set up the initial standard ins and outs
         String mode = Options.unbuffered ? "b" : "";
diff --git a/src/org/python/core/imp.java b/src/org/python/core/imp.java
--- a/src/org/python/core/imp.java
+++ b/src/org/python/core/imp.java
@@ -341,7 +341,9 @@
     public static PyObject createFromSource(String name, InputStream fp,
             String filename, String outFilename, long mtime) {
         byte[] bytes = compileSource(name, fp, filename, mtime);
-        outFilename = cacheCompiledSource(filename, outFilename, bytes);
+        if (!Py.getSystemState().dont_write_bytecode) {
+            outFilename = cacheCompiledSource(filename, outFilename, bytes);
+        }
 
         Py.writeComment(IMPORT_LOG, "'" + name + "' as " + filename);
 
diff --git a/src/org/python/util/jython.java b/src/org/python/util/jython.java
--- a/src/org/python/util/jython.java
+++ b/src/org/python/util/jython.java
@@ -39,7 +39,7 @@
 
     private static final String usage = usageHeader +
         "Options and arguments:\n" + //(and corresponding environment variables):\n" +
-        //"-B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n" +
+        "-B     : don't write .py[co] files on import\n" + // "; also PYTHONDONTWRITEBYTECODE=x\n" +
         "-c cmd   : program passed in as string (terminates option list)\n" +
         //"-d       : debug output from parser (also PYTHONDEBUG=x)\n" +
         "-Dprop=v : Set the property `prop' to value `v'\n"+
@@ -435,6 +435,8 @@
                 Options.verbose +=3 ;
             } else if (arg.equals("-S")) {
                 Options.importSite = false;
+            } else if (arg.equals("-B")) {
+                Options.dontWriteBytecode = true;
             } else if (arg.startsWith("-c")) {
                 runCommand = true;
                 if (arg.length() > 2) {

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list