[PATCH 2 of 3] py3: condiionalize thread import

Yuya Nishihara yuya at tcha.org
Fri Jul 1 10:08:33 EDT 2016


On Thu, 30 Jun 2016 15:17:19 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1467113601 -19800
> #      Tue Jun 28 17:03:21 2016 +0530
> # Node ID 91320eb3d9ce90433ec843525e5563dbad5193e2
> # Parent  752f11e6e60f6214335dd761e6bb045d63747bbb
> py3: condiionalize thread import
> 
> The thread module is renamed to _thread in python 3. Now we import util.thread and
>  hence a test is added in check-code too.
> 
> diff -r 752f11e6e60f -r 91320eb3d9ce contrib/check-code.py
> --- a/contrib/check-code.py	Tue Jun 28 16:01:53 2016 +0530
> +++ b/contrib/check-code.py	Tue Jun 28 17:03:21 2016 +0530
> @@ -331,6 +331,7 @@
>      (r'^import cPickle', "don't use cPickle, use util.pickle"),
>      (r'^import pickle', "don't use pickle, use util.pickle"),
>      (r'^import httplib', "don't use httplib, use util.httplib"),
> +    (r'^import thread\n', "don't use thread, use util.thread"),
>      (r'\.next\(\)', "don't use .next(), use next(...)"),
>  
>      # rules depending on implementation of repquote()
> diff -r 752f11e6e60f -r 91320eb3d9ce mercurial/keepalive.py
> --- a/mercurial/keepalive.py	Tue Jun 28 16:01:53 2016 +0530
> +++ b/mercurial/keepalive.py	Tue Jun 28 17:03:21 2016 +0530
> @@ -113,12 +113,12 @@
>  import hashlib
>  import socket
>  import sys
> -import thread
>  
>  from . import (
>      util,
>  )
>  
> +thread = util.thread

We'd better use threading.Lock. The thread module was renamed to _thread
because it was considered low-level.


More information about the Mercurial-devel mailing list