Comments
Patch
@@ -137,10 +137,9 @@ if sys.version_info[0] >= 3:
# Only handle Mercurial-related modules.
if not fullname.startswith(('mercurial.', 'hgext.', 'hgext3rd.')):
return None
- # This assumes Python 3 doesn't support loading C modules.
- if fullname in _dualmodules:
+ if fullname in _dualmodules and modulepolicy in policy.policynoc:
stem = fullname.split('.')[-1]
fullname = 'mercurial.pure.%s' % stem
target = pure
assert len(path) == 1
@@ -164,11 +163,12 @@ if sys.version_info[0] >= 3:
if fullname.startswith('mercurial.pure.'):
spec.name = spec.name.replace('.pure.', '.')
- # TODO need to support loaders from alternate specs, like zip
- # loaders.
- spec.loader = hgloader(spec.name, spec.origin)
+ if fullname not in _dualmodules:
+ # TODO need to support loaders from alternate specs, like zip
+ # loaders.
+ spec.loader = hgloader(spec.name, spec.origin)
return spec
def replacetokens(tokens, fullname):
"""Transform a stream of tokens from raw to Python 3.
@@ -35,11 +35,6 @@ except ImportError:
# But we don't import platform and don't bloat for it here.
if '__pypy__' in sys.builtin_module_names:
policy = 'cffi'
-# Our C extensions aren't yet compatible with Python 3. So use pure Python
-# on Python 3 for now.
-if sys.version_info[0] >= 3:
- policy = 'py'
-
# Environment variable can always force settings.
policy = os.environ.get('HGMODULEPOLICY', policy)