[PATCH 4 of 6] socketserver: force demandimport to load python3-only modules
Jun Wu
quark at fb.com
Mon May 9 00:06:23 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1462531194 -3600
# Fri May 06 11:39:54 2016 +0100
# Node ID 7a84412fa25901e35b2d791b704aa3d2e3dd434f
# Parent 0e68b512f4d9dad9c064342b0deebd45238f0cdf
socketserver: force demandimport to load python3-only modules
The current socketserver has some "except ImportError" code to detect Python 3
only features and fallback to Python 2 gracefully. With demandimport enabled,
the ImportError will be deferred and the fallback code will not run.
This patch addresses the issue by accessing a member of those modules, forcing
demandimport to load them.
diff --git a/mercurial/socketserver.py b/mercurial/socketserver.py
--- a/mercurial/socketserver.py
+++ b/mercurial/socketserver.py
@@ -136,6 +136,7 @@
import socket
try:
import threading
+ threading.Thread # force demandimport to load the module
except ImportError:
import dummy_threading as threading
@@ -164,6 +165,7 @@
try:
import selectors
+ selectors.EVENT_READ # force demandimport to load the module
except ImportError:
# Python 2 does not have selectors. This is a minimal "selectors"
# module just satisfying the needs of the "socketserver" module.
More information about the Mercurial-devel
mailing list