[wip] mount py3 compatibility improvements
@@ -368,27 +368,61 @@ class ListdirPatch(base.FunctionPatch):
replacement = listdir
-class OpenPatch(base.FunctionPatch):
+class Py2OpenPatch(base.FunctionPatch):
+ """patch for builtins.open()"""
+ PY3 = base.SKIP
+ module = "__builtin__"
+ function = "open"
+ replacement = open
+
+
+class Py3OpenPatch(base.FunctionPatch):
+ """patch for builtins.open()"""
+ PY2 = base.SKIP
+ module = "builtins"
+ function = "open"
+ replacement = open
+
+
+class SixOpenPatch(base.FunctionPatch):
"""patch for builtins.open()"""
module = "six.moves.builtins"
function = "open"
replacement = open
-class GetcwdPatch(base.FunctionPatch):
+class Py2GetcwdPatch(base.FunctionPatch):
"""patch for os.getcwd()"""
+ PY3 = base.SKIP
module = "os"
function = "getcwd"
replacement = getcwd
-class GetcwduPatch(base.FunctionPatch):
+class Py3GetcwdPatch(base.FunctionPatch):
+ """patch for os.getcwd()"""
+ PY2 = base.SKIP
+ module = "os"
+ function = "getcwd"
+ replacement = getcwdu
+
+
+class Py2GetcwduPatch(base.FunctionPatch):
"""patch for os.getcwdu()"""
+ PY3 = base.SKIP
module = "os"
function = "getcwdu"
replacement = getcwdu
+class Py3GetcwdbPatch(base.FunctionPatch):
+ """patch for os.getcwd()"""
+ PY2 = base.SKIP
+ module = "os"
+ function = "getcwdb"
+ replacement = getcwd
+
+
class ChdirPatch(base.FunctionPatch):
"""patch for os.chdir()."""
module = "os"
@@ -455,9 +489,16 @@ class ChmodPatch(base.FunctionPatch):
# create patch instances
LISTDIR_PATCH = ListdirPatch()
-OPEN_PATCH = OpenPatch()
-GETCWD_PATCH = GetcwdPatch()
-GETCWDU_PATCH = GetcwduPatch()
+
+PY2_OPEN_PATCH = Py2OpenPatch()
+PY3_OPEN_PATCH = Py3OpenPatch()
+SIX_OPEN_PATCH = SixOpenPatch()
+
+PY2_GETCWD_PATCH = Py2GetcwdPatch()
+PY3_GETCWD_PATCH = Py3GetcwdPatch()
+PY2_GETCWDU_PATCH = Py2GetcwduPatch()
+PY3_GETCWDB_PATCH = Py3GetcwdbPatch()
+
CHDIR_PATCH = ChdirPatch()
ISMOUNT_PATCH = IsmountPatch()
STAT_PATCH = StatPatch()
