Commits

Frank Wierzbicki committed f1771cd

Add gi_code to generators.

  • Participants
  • Parent commits 31f6376

Comments (0)

Files changed (2)

Lib/test/test_generators.py

 >>> 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

src/org/python/core/PyGenerator.java

     protected PyFrame gi_frame;
 
     @ExposedGet
+    protected PyCode gi_code = null;
+
+    @ExposedGet
     protected boolean gi_running;
 
     private PyObject closure;
     public PyGenerator(PyFrame frame, PyObject closure) {
         super(TYPE);
         gi_frame = frame;
+        if (gi_frame != null) {
+            gi_code = gi_frame.f_code;
+        }
         this.closure = closure;
     }