Add back, but deprecate, Python 2/3 compatibility layer
Not all old utils were added back because some weren't expected to be
used externally. If that assumption is wrong, we can add more utils
later.
Fixes
@@ -76,3 +76,29 @@ from .unic import prepr, safe_str
def read_rest_data(rstfile):
from .restreader import read_rest_data
return read_rest_data(rstfile)
+
+
+# Deprecated Python 2/3 compatibility layer. Not needed by Robot Framework itself
+# since Python 2 support was dropped in RF 5. Preserved at least until RF 5.2
+# to avoid breaking external libraries and tools that use it.
+# https://github.com/robotframework/robotframework/issues/4150
+
+PY3 = True
+PY2 = JYTHON = IRONPYTHON = False
+is_unicode = is_string
+unicode = str
+unic = safe_str
+
+
+def py2to3(cls):
+ """Deprecated since RF 5.0. Use Python 3 features directly instead."""
+ if hasattr(cls, '__unicode__'):
+ cls.__str__ = lambda self: self.__unicode__()
+ if hasattr(cls, '__nonzero__'):
+ cls.__bool__ = lambda self: self.__nonzero__()
+ return cls
+
+
+def py3to2(cls):
+ """Deprecated since RF 5.0. Never done anything when used on Python 3."""
+ return cls
