[pypy-commit] pypy default: Remove OrderedDict compatibility hacks for Python 2.6
rlamy
noreply at buildbot.pypy.org
Thu Oct 15 11:42:15 EDT 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r80242:81593cb4a496
Date: 2015-10-15 16:41 +0100
http://bitbucket.org/pypy/pypy/changeset/81593cb4a496/
Log: Remove OrderedDict compatibility hacks for Python 2.6
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -6,6 +6,7 @@
import sys, types, inspect, weakref
from contextlib import contextmanager
+from collections import OrderedDict
from rpython.flowspace.model import Constant
from rpython.annotator.model import (
@@ -257,12 +258,12 @@
result.const_box = key
return result
elif (tp is dict or tp is r_dict or
- tp is SomeOrderedDict.knowntype or tp is r_ordereddict):
+ tp is OrderedDict or tp is r_ordereddict):
key = Constant(x)
try:
return self.immutable_cache[key]
except KeyError:
- if tp is SomeOrderedDict.knowntype or tp is r_ordereddict:
+ if tp is OrderedDict or tp is r_ordereddict:
cls = SomeOrderedDict
else:
cls = SomeDict
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -2,6 +2,7 @@
Built-in functions.
"""
import sys
+from collections import OrderedDict
from rpython.annotator.model import (
SomeInteger, SomeObject, SomeChar, SomeBool, SomeString, SomeTuple,
@@ -356,7 +357,7 @@
def unicodedata_decimal(s_uchr):
raise TypeError("unicodedate.decimal() calls should not happen at interp-level")
- at analyzer_for(SomeOrderedDict.knowntype)
+ at analyzer_for(OrderedDict)
def analyze():
return SomeOrderedDict(getbookkeeper().getdictdef())
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -32,6 +32,7 @@
import inspect
import weakref
from types import BuiltinFunctionType, MethodType
+from collections import OrderedDict
import rpython
from rpython.tool import descriptor
@@ -377,11 +378,7 @@
return type(self)(self.dictdef)
class SomeOrderedDict(SomeDict):
- try:
- from collections import OrderedDict as knowntype
- except ImportError: # Python 2.6
- class PseudoOrderedDict(dict): pass
- knowntype = PseudoOrderedDict
+ knowntype = OrderedDict
def method_copy(dct):
return SomeOrderedDict(dct.dictdef)
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -1,3 +1,5 @@
+from collections import OrderedDict
+
from rpython.annotator import model as annmodel
from rpython.flowspace.model import Constant
from rpython.rlib import rarithmetic, objectmodel
@@ -721,7 +723,7 @@
raise TyperError("hasattr is only suported on a constant")
- at typer_for(annmodel.SomeOrderedDict.knowntype)
+ at typer_for(OrderedDict)
@typer_for(objectmodel.r_dict)
@typer_for(objectmodel.r_ordereddict)
def rtype_dict_constructor(hop, i_force_non_null=None):
More information about the pypy-commit
mailing list