1. Pypy
  2. Untitled project
  3. pypy


Amaury Forgeot d'Arc  committed e0d46e4

Hack RPython context managers differently:
on RPython, the __exit__ method will now receive (None, None, None) when
there is no exception, and (exc_value, exc_value, None) when there is
an exception; i.e. the exception type is not passed.

  • Participants
  • Parent commits 55bfb1c
  • Branches default

Comments (0)

Files changed (1)

File pypy/objspace/flow/flowcontext.py

View file
     def call_contextmanager_exit_function(self, w_func, w_typ, w_val, w_tb):
         if w_typ is not self.space.w_None:
             # The annotator won't allow to merge exception types with None.
-            # Replace it with an object which will break translation when used
-            # (except maybe with 'exc_typ is None')
-            w_typ = self.space.w_None
+            # Replace it with the exception value...
+            w_typ = w_val
         self.space.call_function(w_func, w_typ, w_val, w_tb)
         # Return None so that the flow space statically knows that we didn't
         # swallow the exception