Message7967

Author seletz
Recipients seletz
Date 2013-03-23.13:19:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1364044762.2.0.698279561967.issue2029@psf.upfronthosting.co.za>
In-reply-to
Content
Maybe something like this could help:

--- codeop.py.orig	2013-03-23 14:06:50.000000000 +0100
+++ codeop.py	2013-03-23 14:13:21.000000000 +0100
@@ -87,17 +87,33 @@
     symbol = CompileMode.getMode(symbol)
     return Py.compile_command_flags(source,filename,symbol,Py.getCompilerFlags(),0)

+class CompilerFlagsWrapper(object):
+    def __init__(self):
+        self._flags = CompilerFlags()
+
+    def __get__(self, f, tp):
+        return self._flags.toBits()
+
+    def __set__(self, f):
+        self._flags = CompilerFlags(f)
+
+    def __or__(self, f):
+        self._flags = self._flags.combine(f)
+
 class Compile:
     """Instances of this class behave much like the built-in compile
     function, but if one is used to compile text containing a future
     statement, it "remembers" and compiles all subsequent program texts
     with the statement in force."""
+
     def __init__(self):
-        self._cflags = CompilerFlags()
+        pass
+
+    flags = CompilerFlagsWrapper()

     def __call__(self, source, filename, symbol):
         symbol = CompileMode.getMode(symbol)
-        return Py.compile_flags(source, filename, symbol, self._cflags)
+        return Py.compile_flags(source, filename, symbol, CompilerFlags(self.flags))

 class CommandCompiler:
     """Instances of this class have __call__ methods identical in
@@ -106,8 +122,10 @@
     the instance 'remembers' and compiles all subsequent program texts
     with the statement in force."""

-    def __init__(self,):
-        self._cflags = CompilerFlags()
+    def __init__(self):
+        pass
+
+    flags = CompilerFlagsWrapper()

     def __call__(self, source, filename="<input>", symbol="single"):
         r"""Compile a command and determine whether it is incomplete.
@@ -131,4 +149,4 @@
         if symbol not in ['single','eval']:
             raise ValueError,"symbol arg must be either single or eval"
         symbol = CompileMode.getMode(symbol)
-        return Py.compile_command_flags(source,filename,symbol,self._cflags,0)
+        return Py.compile_command_flags(source,filename,symbol,CompilerFlags(self.flags),0)
History
Date User Action Args
2013-03-23 13:19:22seletzsetmessageid: <1364044762.2.0.698279561967.issue2029@psf.upfronthosting.co.za>
2013-03-23 13:19:22seletzsetrecipients: + seletz
2013-03-23 13:19:22seletzlinkissue2029 messages
2013-03-23 13:19:21seletzcreate