[pypy-commit] pypy exc-later: Replace all uses of SomeExceptCase with SomeInstance
rlamy
noreply at buildbot.pypy.org
Sun Nov 22 13:00:03 EST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: exc-later
Changeset: r80834:bcf830d9e710
Date: 2015-11-22 05:38 +0000
http://bitbucket.org/pypy/pypy/changeset/bcf830d9e710/
Log: Replace all uses of SomeExceptCase with SomeInstance
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -11,7 +11,7 @@
from rpython.translator import simplify, transform
from rpython.annotator import model as annmodel, signature
from rpython.annotator.model import (
- typeof, SomeExceptCase, s_ImpossibleValue, SomeInstance)
+ typeof, s_ImpossibleValue, SomeInstance)
from rpython.annotator.bookkeeper import Bookkeeper
from rpython.rtyper.normalizecalls import perform_normalizations
@@ -496,8 +496,7 @@
continue
if s_exception == s_ImpossibleValue:
break
- s_case = SomeExceptCase(
- self.bookkeeper.getuniqueclassdef(case))
+ s_case = SomeInstance(self.bookkeeper.getuniqueclassdef(case))
s_matching_exc = s_exception.intersection(s_case)
if s_matching_exc != s_ImpossibleValue:
self.follow_raise_link(graph, link, s_matching_exc)
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -446,17 +446,18 @@
return None
def intersection(self, other):
- assert isinstance(other, SomeExceptCase)
- if self.classdef.issubclass(other.case):
- return self
- elif other.case.issubclass(self.classdef):
- return SomeInstance(other.case)
+ assert isinstance(other, SomeInstance)
+ can_be_None = self.can_be_None and other.can_be_None
+ if self.classdef.issubclass(other.classdef):
+ return SomeInstance(self.classdef, can_be_None=can_be_None)
+ elif other.classdef.issubclass(self.classdef):
+ return SomeInstance(other.classdef, can_be_None=can_be_None)
else:
return s_ImpossibleValue
def difference(self, other):
- assert isinstance(other, SomeExceptCase)
- if self.classdef.issubclass(other.case):
+ assert isinstance(other, SomeInstance)
+ if self.classdef.issubclass(other.classdef):
return s_ImpossibleValue
else:
return self
@@ -476,16 +477,16 @@
self.classdefs = classdefs
def intersection(self, other):
- assert isinstance(other, SomeExceptCase)
- classdefs = {c for c in self.classdefs if c.issubclass(other.case)}
+ assert isinstance(other, SomeInstance)
+ classdefs = {c for c in self.classdefs if c.issubclass(other.classdef)}
if classdefs:
return SomeException(classdefs)
else:
return s_ImpossibleValue
def difference(self, other):
- assert isinstance(other, SomeExceptCase)
- classdefs = {c for c in self.classdefs if not c.issubclass(other.case)}
+ assert isinstance(other, SomeInstance)
+ classdefs = {c for c in self.classdefs if not c.issubclass(other.classdef)}
if classdefs:
return SomeException(classdefs)
else:
@@ -495,15 +496,6 @@
return unionof(*[SomeInstance(cdef) for cdef in self.classdefs])
-class SomeExceptCase(SomeObject):
- """The set of exceptions that match a given except clause.
-
- IOW, the set of exceptions that verify isinstance(exc, self.case).
- """
- def __init__(self, case):
- self.case = case
-
-
class SomePBC(SomeObject):
"""Stands for a global user instance, built prior to the analysis,
or a set of such instances."""
More information about the pypy-commit
mailing list