Patchwork util: correct check of sys.version_info

login
register
mail settings
Submitter Augie Fackler
Date Oct. 7, 2016, 12:48 p.m.
Message ID <12048b2934186bf24740.1475844482@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/16883/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 7, 2016, 12:48 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1475841676 14400
#      Fri Oct 07 08:01:16 2016 -0400
# Node ID 12048b2934186bf24740640fd88412a7218deb44
# Parent  f3a2125968377fb1d4b9ea3f4917260d5aca3536
util: correct check of sys.version_info

sys.version is a string, and shouldn't be compared against a tuple for
version comparisons. This was always true, so we were never disabling
gc on 2.6.

>>> (2, 7) >= '2.7'
True
>>> (2, 6) >= '2.7'
True
Martijn Pieters - Oct. 7, 2016, 12:52 p.m.
On 7 October 2016 at 14:48, Augie Fackler <raf@durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1475841676 14400
> #      Fri Oct 07 08:01:16 2016 -0400
> # Node ID 12048b2934186bf24740640fd88412a7218deb44
> # Parent  f3a2125968377fb1d4b9ea3f4917260d5aca3536
> util: correct check of sys.version_info
>
> sys.version is a string, and shouldn't be compared against a tuple for
> version comparisons. This was always true, so we were never disabling
> gc on 2.6.
>
>>>> (2, 7) >= '2.7'
> True
>>>> (2, 6) >= '2.7'
> True

Obvious fix is obvious. Rubberstamped!

> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -881,7 +881,7 @@ def nogc(func):
>
>      This garbage collector issue have been fixed in 2.7.
>      """
> -    if sys.version >= (2, 7):
> +    if sys.version_info >= (2, 7):
>          return func
>      def wrapper(*args, **kwargs):
>          gcenabled = gc.isenabled()
> 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
> @@ -162,10 +162,10 @@
>    mercurial/ui.py: error importing: <TypeError> int() can't convert non-string with explicit base (error at util.py:*)
>    mercurial/unionrepo.py: error importing: <TypeError> int() can't convert non-string with explicit base (error at util.py:*)
>    mercurial/url.py: error importing: <TypeError> int() can't convert non-string with explicit base (error at util.py:*)
> -  mercurial/verify.py: error importing module: <TypeError> unorderable types: str() >= tuple() (line *)
> +  mercurial/verify.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at revset.py:*)
>    mercurial/win32.py: error importing module: <ImportError> No module named 'msvcrt' (line *)
>    mercurial/windows.py: error importing module: <ImportError> No module named 'msvcrt' (line *)
> -  mercurial/wireproto.py: error importing module: <TypeError> unorderable types: str() >= tuple() (line *)
> +  mercurial/wireproto.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at revset.py:*)
>
>  #endif
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -881,7 +881,7 @@  def nogc(func):
 
     This garbage collector issue have been fixed in 2.7.
     """
-    if sys.version >= (2, 7):
+    if sys.version_info >= (2, 7):
         return func
     def wrapper(*args, **kwargs):
         gcenabled = gc.isenabled()
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
@@ -162,10 +162,10 @@ 
   mercurial/ui.py: error importing: <TypeError> int() can't convert non-string with explicit base (error at util.py:*)
   mercurial/unionrepo.py: error importing: <TypeError> int() can't convert non-string with explicit base (error at util.py:*)
   mercurial/url.py: error importing: <TypeError> int() can't convert non-string with explicit base (error at util.py:*)
-  mercurial/verify.py: error importing module: <TypeError> unorderable types: str() >= tuple() (line *)
+  mercurial/verify.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at revset.py:*)
   mercurial/win32.py: error importing module: <ImportError> No module named 'msvcrt' (line *)
   mercurial/windows.py: error importing module: <ImportError> No module named 'msvcrt' (line *)
-  mercurial/wireproto.py: error importing module: <TypeError> unorderable types: str() >= tuple() (line *)
+  mercurial/wireproto.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at revset.py:*)
 
 #endif