# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2016-08-08 18:21:11 # Node ID e584c623550076d0443c397ff815cb7bb5dbe821 # Parent 2372182e505b2201c7c35476ab3ebca85c28b071 py3: conditionalize the raise statement raise E,V,T is not acceptable in Python 3, thats is conditionalized. Moreover this will result in syntax error so we have to use exec() to execute this. Related PEP- https://www.python.org/dev/peps/pep-3109/#id14 My implementation is motivated from the six implementation except they are defining a new function exec_() to prevent adding an extra frame AFAIK :) https://bitbucket.org/gutworth/six/src/ca4580a5a648/six.py#six.py-680 diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -989,7 +989,10 @@ class bundlepart(object): outdebug(ui, 'closing payload chunk') # abort current part payload yield _pack(_fpayloadsize, 0) - raise exc_info[0], exc_info[1], exc_info[2] + if sys.version_info[0] >= 3: + raise exc_info[0](exc_info[1]).with_traceback(exc_info[2]) + else: + exec("""raise exc_info[0], exc_info[1], exc_info[2]""") # end of payload outdebug(ui, 'closing payload chunk') yield _pack(_fpayloadsize, 0) diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t +++ b/tests/test-check-py3-compat.t @@ -81,7 +81,7 @@ mercurial/archival.py: invalid syntax: invalid syntax (, line *) (glob) mercurial/bookmarks.py: error importing: str expected, not bytes (error at encoding.py:*) (glob) mercurial/branchmap.py: error importing: str expected, not bytes (error at encoding.py:*) (glob) - mercurial/bundle2.py: invalid syntax: invalid syntax (, line *) (glob) + mercurial/bundle2.py: error importing: str expected, not bytes (error at encoding.py:*) (glob) mercurial/bundlerepo.py: error importing: str expected, not bytes (error at encoding.py:*) (glob) mercurial/byterange.py: error importing: str expected, not bytes (error at encoding.py:*) (glob) mercurial/changegroup.py: error importing: str expected, not bytes (error at encoding.py:*) (glob) @@ -141,7 +141,7 @@ mercurial/pushkey.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/pvec.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/registrar.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) - mercurial/repair.py: error importing module: invalid syntax (bundle2.py, line *) (line *) (glob) + mercurial/repair.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) mercurial/repoview.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) mercurial/revlog.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) mercurial/revset.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) @@ -168,6 +168,6 @@ mercurial/verify.py: error importing: attribute name must be string, not 'bytes' (error at mdiff.py:*) (glob) mercurial/win32.py: error importing module: No module named 'msvcrt' (line *) (glob) mercurial/windows.py: error importing module: No module named '_winreg' (line *) (glob) - mercurial/wireproto.py: error importing module: invalid syntax (bundle2.py, line *) (line *) (glob) + mercurial/wireproto.py: error importing module: a bytes-like object is required, not 'str' (line *) (glob) #endif