Submitter | Augie Fackler |
---|---|
Date | Aug. 22, 2017, 7:08 p.m. |
Message ID | <d31f856bd5d31a1adc37.1503428933@imladris.local> |
Download | mbox | patch |
Permalink | /patch/23211/ |
State | Superseded |
Headers | show |
Comments
This patch flunks test-check-code.t, please disregard this series in favor of a forthcoming v2. > On Aug 22, 2017, at 3:08 PM, Augie Fackler <raf@durin42.com> wrote: > > # HG changeset patch > # User Augie Fackler <raf@durin42.com> > # Date 1503413909 14400 > # Tue Aug 22 10:58:29 2017 -0400 > # Node ID d31f856bd5d31a1adc377f2679da764b85700bf0 > # Parent ccb38cfe8b6d7833490e9db28eda18968f27c490 > contrib: work around some modules not existing on Py3 in import checker > > diff --git a/contrib/import-checker.py b/contrib/import-checker.py > --- a/contrib/import-checker.py > +++ b/contrib/import-checker.py > @@ -12,7 +12,10 @@ import sys > # to work when run from a virtualenv. The modules were chosen empirically > # so that the return value matches the return value without virtualenv. > if True: # disable lexical sorting checks > - import BaseHTTPServer > + try: > + import BaseHTTPServer > + except ImportError: > + BaseHTTPServer = None > import zlib > > # Whitelist of modules that symbols can be directly imported from. > @@ -183,8 +186,9 @@ def populateextmods(localmods): > def list_stdlib_modules(): > """List the modules present in the stdlib. > > + >>> py3 = sys.version_info[0] >= 3 >>>> mods = set(list_stdlib_modules()) > - >>> 'BaseHTTPServer' in mods > + >>> 'BaseHTTPServer' in mods or py3 > True > > os.path isn't really a module, so it's missing: > @@ -201,7 +205,7 @@ def list_stdlib_modules(): >>>> 'collections' in mods > True > > - >>> 'cStringIO' in mods > + >>> 'cStringIO' in mods or py3 > True > >>>> 'cffi' in mods > @@ -224,6 +228,8 @@ def list_stdlib_modules(): > # We need to supplement the list of prefixes for the search to work > # when run from within a virtualenv. > for mod in (BaseHTTPServer, zlib): > + if mod is None: > + continue > try: > # Not all module objects have a __file__ attribute. > filename = mod.__file__ > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Patch
diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -12,7 +12,10 @@ import sys # to work when run from a virtualenv. The modules were chosen empirically # so that the return value matches the return value without virtualenv. if True: # disable lexical sorting checks - import BaseHTTPServer + try: + import BaseHTTPServer + except ImportError: + BaseHTTPServer = None import zlib # Whitelist of modules that symbols can be directly imported from. @@ -183,8 +186,9 @@ def populateextmods(localmods): def list_stdlib_modules(): """List the modules present in the stdlib. + >>> py3 = sys.version_info[0] >= 3 >>> mods = set(list_stdlib_modules()) - >>> 'BaseHTTPServer' in mods + >>> 'BaseHTTPServer' in mods or py3 True os.path isn't really a module, so it's missing: @@ -201,7 +205,7 @@ def list_stdlib_modules(): >>> 'collections' in mods True - >>> 'cStringIO' in mods + >>> 'cStringIO' in mods or py3 True >>> 'cffi' in mods @@ -224,6 +228,8 @@ def list_stdlib_modules(): # We need to supplement the list of prefixes for the search to work # when run from within a virtualenv. for mod in (BaseHTTPServer, zlib): + if mod is None: + continue try: # Not all module objects have a __file__ attribute. filename = mod.__file__