Author: Armin Rigo <ar...@tunes.org> Branch: exception-cannot-occur Changeset: r54125:6ec59dc45235 Date: 2012-04-01 19:03 +0200 http://bitbucket.org/pypy/pypy/changeset/6ec59dc45235/
Log: Add the logic to detect missing cases. diff --git a/pypy/rpython/rbuiltin.py b/pypy/rpython/rbuiltin.py --- a/pypy/rpython/rbuiltin.py +++ b/pypy/rpython/rbuiltin.py @@ -111,25 +111,32 @@ raise TyperError("don't know about built-in function %r" % ( self.builtinfunc,)) + def _call(self, hop2, **kwds_i): + bltintyper = self.findbltintyper(hop2.rtyper) + hop2.llops._called_exception_is_here_or_cannot_occur = False + v_result = bltintyper(hop2, **kwds_i) + if not hop2.llops._called_exception_is_here_or_cannot_occur: + raise TyperError("missing hop.exception_cannot_occur() or " + "hop.exception_is_here() in %s" % bltintyper) + return v_result + def rtype_simple_call(self, hop): - bltintyper = self.findbltintyper(hop.rtyper) hop2 = hop.copy() hop2.r_s_popfirstarg() - return bltintyper(hop2) + return self._call(hop2) def rtype_call_args(self, hop): # calling a built-in function with keyword arguments: # mostly for rpython.objectmodel.hint() hop, kwds_i = call_args_expand(hop) - bltintyper = self.findbltintyper(hop.rtyper) hop2 = hop.copy() hop2.r_s_popfirstarg() hop2.r_s_popfirstarg() # the RPython-level keyword args are passed with an 'i_' prefix and # the corresponding value is an *index* in the hop2 arguments, # to be used with hop.inputarg(arg=..) - return bltintyper(hop2, **kwds_i) + return self._call(hop2, **kwds_i) class BuiltinMethodRepr(Repr): @@ -264,6 +271,7 @@ pass def rtype_OSError__init__(hop): + hop.exception_cannot_occur() if hop.nb_args == 2: raise TyperError("OSError() should not be called with " "a single argument") @@ -274,6 +282,7 @@ r_self.setfield(v_self, 'errno', v_errno, hop.llops) def rtype_WindowsError__init__(hop): + hop.exception_cannot_occur() if hop.nb_args == 2: raise TyperError("WindowsError() should not be called with " "a single argument") diff --git a/pypy/rpython/rtyper.py b/pypy/rpython/rtyper.py --- a/pypy/rpython/rtyper.py +++ b/pypy/rpython/rtyper.py @@ -846,6 +846,7 @@ return result def exception_is_here(self): + self.llops._called_exception_is_here_or_cannot_occur = True if self.llops.llop_raising_exceptions is not None: raise TyperError("cannot catch an exception at more than one llop") if not self.exceptionlinks: @@ -861,6 +862,7 @@ self.llops.llop_raising_exceptions = len(self.llops) def exception_cannot_occur(self): + self.llops._called_exception_is_here_or_cannot_occur = True if self.llops.llop_raising_exceptions is not None: raise TyperError("cannot catch an exception at more than one llop") if not self.exceptionlinks: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit