[Jython-checkins] jython: Add gi_code to generators.
frank.wierzbicki
jython-checkins at python.org
Fri Jun 8 19:00:27 CEST 2012
http://hg.python.org/jython/rev/f1771cd8f5f3
changeset: 6688:f1771cd8f5f3
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Fri Jun 08 09:59:59 2012 -0700
summary:
Add gi_code to generators.
files:
Lib/test/test_generators.py | 2 +-
src/org/python/core/PyGenerator.java | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -382,7 +382,7 @@
>>> type(i)
<type 'generator'>
>>> [s for s in dir(i) if not s.startswith('_')]
-['close', 'gi_frame', 'gi_running', 'next', 'send', 'throw']
+['close', 'gi_code', 'gi_frame', 'gi_running', 'next', 'send', 'throw']
>>> print i.next.__doc__
x.next() -> the next value, or raise StopIteration
>>> iter(i) is i
diff --git a/src/org/python/core/PyGenerator.java b/src/org/python/core/PyGenerator.java
--- a/src/org/python/core/PyGenerator.java
+++ b/src/org/python/core/PyGenerator.java
@@ -14,6 +14,9 @@
protected PyFrame gi_frame;
@ExposedGet
+ protected PyCode gi_code = null;
+
+ @ExposedGet
protected boolean gi_running;
private PyObject closure;
@@ -21,6 +24,9 @@
public PyGenerator(PyFrame frame, PyObject closure) {
super(TYPE);
gi_frame = frame;
+ if (gi_frame != null) {
+ gi_code = gi_frame.f_code;
+ }
this.closure = closure;
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list