[PATCH] util: correct check of sys.version_info

Martijn Pieters mj at zopatista.com
Fri Oct 7 08:52:12 EDT 2016


On 7 October 2016 at 14:48, Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie at 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 at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



-- 
Martijn Pieters


More information about the Mercurial-devel mailing list