[Checkins] SVN: zope.deprecation/branches/chrism-unittesting/src/zope/deprecation/deprecation.py py3 compat
Chris McDonough
chrism at plope.com
Sun Sep 4 18:01:30 EST 2011
Log message for revision 122721:
py3 compat
Changed:
U zope.deprecation/branches/chrism-unittesting/src/zope/deprecation/deprecation.py
-=-
Modified: zope.deprecation/branches/chrism-unittesting/src/zope/deprecation/deprecation.py
===================================================================
--- zope.deprecation/branches/chrism-unittesting/src/zope/deprecation/deprecation.py 2011-09-04 22:42:02 UTC (rev 122720)
+++ zope.deprecation/branches/chrism-unittesting/src/zope/deprecation/deprecation.py 2011-09-04 23:01:27 UTC (rev 122721)
@@ -21,6 +21,13 @@
import types
import warnings
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+ str_and_sequence_types = (str, list, tuple)
+else:
+ str_and_sequence_types = (basestring, list, tuple)
+
class ShowSwitch(object):
"""Simple stack-based switch."""
@@ -153,14 +160,13 @@
return deprecated_method
-
def deprecated(specifier, message):
"""Deprecate the given names."""
# A string specifier (or list of strings) means we're called
# top-level in a module and are to deprecate things inside this
# module
- if isinstance(specifier, (str, unicode, list, tuple)):
+ if isinstance(specifier, str_and_sequence_types):
globals = sys._getframe(1).f_globals
modname = globals['__name__']
@@ -208,7 +214,7 @@
tomod = sys.modules[old]
tomod.__doc__ = message
- for name, v in fromdict.iteritems():
+ for name, v in fromdict.items():
if name not in tomod.__dict__:
setattr(tomod, name, v)
More information about the checkins
mailing list