Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r76601:7c4eccd92fb9
Date: 2015-03-27 18:53 +0000
http://bitbucket.org/pypy/pypy/changeset/7c4eccd92fb9/
Log: Move FORCE_ATTRIBUTES_INTO_CLASSES to the only place where it's used
diff --git a/rpython/annotator/classdef.py b/rpython/annotator/classdef.py
--- a/rpython/annotator/classdef.py
+++ b/rpython/annotator/classdef.py
@@ -2,8 +2,7 @@
Type inference for user-defined classes.
"""
from rpython.annotator.model import (
- SomePBC, s_ImpossibleValue, unionof, s_None, SomeInteger,
- SomeTuple, SomeString, AnnotatorError, SomeUnicodeString)
+ SomePBC, s_ImpossibleValue, unionof, s_None, AnnotatorError)
from rpython.annotator import description
@@ -437,18 +436,3 @@
class NoSuchAttrError(AnnotatorError):
"""Raised when an attribute is found on a class where __slots__
or _attrs_ forbits it."""
-
-# ____________________________________________________________
-
-FORCE_ATTRIBUTES_INTO_CLASSES = {
- EnvironmentError: {'errno': SomeInteger(),
- 'strerror': SomeString(can_be_None=True),
- 'filename': SomeString(can_be_None=True)},
-}
-
-try:
- WindowsError
-except NameError:
- pass
-else:
- FORCE_ATTRIBUTES_INTO_CLASSES[WindowsError] = {'winerror': SomeInteger()}
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -7,7 +7,7 @@
from rpython.annotator.argument import rawshape, ArgErr
from rpython.tool.sourcetools import valid_identifier, func_with_new_name
from rpython.tool.pairtype import extendabletype
-from rpython.annotator.model import AnnotatorError
+from rpython.annotator.model import AnnotatorError, SomeInteger, SomeString
class CallFamily(object):
"""A family of Desc objects that could be called from common call sites.
@@ -477,8 +477,7 @@
if (self.is_builtin_exception_class() and
self.all_enforced_attrs is None):
- from rpython.annotator import classdef
- if cls not in classdef.FORCE_ATTRIBUTES_INTO_CLASSES:
+ if cls not in FORCE_ATTRIBUTES_INTO_CLASSES:
self.all_enforced_attrs = [] # no attribute allowed
def add_source_attribute(self, name, value, mixin=False):
@@ -573,8 +572,7 @@
try:
return self._classdefs[key]
except KeyError:
- from rpython.annotator.classdef import (
- ClassDef, FORCE_ATTRIBUTES_INTO_CLASSES)
+ from rpython.annotator.classdef import ClassDef
classdef = ClassDef(self.bookkeeper, self)
self.bookkeeper.classdefs.append(classdef)
self._classdefs[key] = classdef
@@ -1077,3 +1075,18 @@
MemberDescriptorTypes.append(type(OSError.errno))
except AttributeError: # on CPython <= 2.4
pass
+
+# ____________________________________________________________
+
+FORCE_ATTRIBUTES_INTO_CLASSES = {
+ EnvironmentError: {'errno': SomeInteger(),
+ 'strerror': SomeString(can_be_None=True),
+ 'filename': SomeString(can_be_None=True)},
+}
+
+try:
+ WindowsError
+except NameError:
+ pass
+else:
+ FORCE_ATTRIBUTES_INTO_CLASSES[WindowsError] = {'winerror': SomeInteger()}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit