Compatibility with PyPy

On PyPy, dict.__reversed__ exists and raises a TypeError, on CPython, it
doesn't.

However, reversed({}) behaves the same on both sides.
This commit is contained in:
Markus Unterwaditzer 2015-02-23 00:22:00 +01:00
parent f88e5f836d
commit c8a7ad36de

View file

@ -40,8 +40,12 @@ del _process_properties
#
# This basically checks whether the superclass of all icalendar classes has a
# method from OrderedDict.
ICALENDAR_ORIGINAL_ORDER_SUPPORT = \
hasattr(icalendar.caselessdict.CaselessDict, '__reversed__')
try:
reversed(icalendar.caselessdict.CaselessDict())
except TypeError:
ICALENDAR_ORIGINAL_ORDER_SUPPORT = False
else:
ICALENDAR_ORIGINAL_ORDER_SUPPORT = True
class Item(object):