mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	merge 3.2 (#12475)
This commit is contained in:
		
						commit
						7b7099c36f
					
				
					 3 changed files with 23 additions and 4 deletions
				
			
		| 
						 | 
					@ -567,6 +567,21 @@ def yield_raise():
 | 
				
			||||||
            del g
 | 
					            del g
 | 
				
			||||||
            self.assertEqual(sys.exc_info()[0], TypeError)
 | 
					            self.assertEqual(sys.exc_info()[0], TypeError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_generator_leaking2(self):
 | 
				
			||||||
 | 
					        # See issue 12475.
 | 
				
			||||||
 | 
					        def g():
 | 
				
			||||||
 | 
					            yield
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            raise RuntimeError
 | 
				
			||||||
 | 
					        except RuntimeError:
 | 
				
			||||||
 | 
					            it = g()
 | 
				
			||||||
 | 
					            next(it)
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            next(it)
 | 
				
			||||||
 | 
					        except StopIteration:
 | 
				
			||||||
 | 
					            pass
 | 
				
			||||||
 | 
					        self.assertEqual(sys.exc_info(), (None, None, None))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_generator_finalizing_and_exc_info(self):
 | 
					    def test_generator_finalizing_and_exc_info(self):
 | 
				
			||||||
        # See #7173
 | 
					        # See #7173
 | 
				
			||||||
        def simple_gen():
 | 
					        def simple_gen():
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
 | 
				
			||||||
Core and Builtins
 | 
					Core and Builtins
 | 
				
			||||||
-----------------
 | 
					-----------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Issue #12475: Prevent generators from leaking their exception state into the
 | 
				
			||||||
 | 
					  callers frame as they return for the last time.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Issue #12291: You can now load multiple marshalled objects from a stream,
 | 
					- Issue #12291: You can now load multiple marshalled objects from a stream,
 | 
				
			||||||
  with other data interleaved between marshalled objects.
 | 
					  with other data interleaved between marshalled objects.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1865,10 +1865,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
				
			||||||
            retval = POP();
 | 
					            retval = POP();
 | 
				
			||||||
            f->f_stacktop = stack_pointer;
 | 
					            f->f_stacktop = stack_pointer;
 | 
				
			||||||
            why = WHY_YIELD;
 | 
					            why = WHY_YIELD;
 | 
				
			||||||
            /* Put aside the current exception state and restore
 | 
					 | 
				
			||||||
               that of the calling frame. This only serves when
 | 
					 | 
				
			||||||
               "yield" is used inside an except handler. */
 | 
					 | 
				
			||||||
            SWAP_EXC_STATE();
 | 
					 | 
				
			||||||
            goto fast_yield;
 | 
					            goto fast_yield;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TARGET(POP_EXCEPT)
 | 
					        TARGET(POP_EXCEPT)
 | 
				
			||||||
| 
						 | 
					@ -3005,6 +3001,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
				
			||||||
        retval = NULL;
 | 
					        retval = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fast_yield:
 | 
					fast_yield:
 | 
				
			||||||
 | 
					    if (co->co_flags & CO_GENERATOR && (why == WHY_YIELD || why == WHY_RETURN))
 | 
				
			||||||
 | 
					        /* Put aside the current exception state and restore that of the
 | 
				
			||||||
 | 
					           calling frame. */
 | 
				
			||||||
 | 
					        SWAP_EXC_STATE();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (tstate->use_tracing) {
 | 
					    if (tstate->use_tracing) {
 | 
				
			||||||
        if (tstate->c_tracefunc) {
 | 
					        if (tstate->c_tracefunc) {
 | 
				
			||||||
            if (why == WHY_RETURN || why == WHY_YIELD) {
 | 
					            if (why == WHY_RETURN || why == WHY_YIELD) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue