Issue2029
Created on 2013-03-23.12:08:44 by seletz, last changed 2018-03-07.19:07:17 by jeff.allen.
msg7965 (view) |
Author: Stefan Eletzhofer (seletz) |
Date: 2013-03-23.12:08:44 |
|
The codeop.Compile class doesn't expose the compiler flags
as expected (as a "flags" attribute). The flags seem to be
properly implemented in the com.python.core.CompilerFlags
class, but aren't exposed -- they're exposed as _cflags, but
this is a instance of org.python.core.CompilerFlags.
For instance, IPython tries to enable the PyCF_ONLY_AST flag
for it's caching compiler subclass by or-ing it to an expected
`flags` attribute.
The bit values of the constants implemented in com.python.core.CompilerFlags seem to match the CPython
implementation at a first glance.
|
msg7967 (view) |
Author: Stefan Eletzhofer (seletz) |
Date: 2013-03-23.13:19:21 |
|
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)
|
msg8753 (view) |
Author: Jim Baker (zyasoft) |
Date: 2014-06-19.16:10:46 |
|
Target beta 4
|
msg9419 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-01-17.18:40:16 |
|
Missed in the final triage, let's see if this can get fixed
|
|
Date |
User |
Action |
Args |
2018-03-07 19:07:17 | jeff.allen | set | milestone: Jython 2.7.2 -> |
2017-09-25 03:36:50 | zyasoft | set | resolution: remind |
2015-12-29 23:45:22 | zyasoft | set | milestone: Jython 2.7.1 -> Jython 2.7.2 |
2015-04-15 20:41:29 | zyasoft | set | assignee: zyasoft -> |
2015-04-15 20:41:21 | zyasoft | set | milestone: Jython 2.7.1 |
2015-01-17 18:40:16 | zyasoft | set | priority: normal -> high assignee: zyasoft messages:
+ msg9419 |
2014-06-19 16:10:46 | zyasoft | set | nosy:
+ zyasoft messages:
+ msg8753 |
2013-03-23 20:13:05 | fwierzbicki | set | priority: normal nosy:
+ fwierzbicki |
2013-03-23 13:19:22 | seletz | set | messages:
+ msg7967 |
2013-03-23 12:08:44 | seletz | create | |
|