[PATCH 2 of 2] util: ensure forwarded attrs are set in globals() as sysstr

Pulkit Goyal 7895pulkit at gmail.com
Sat Oct 8 08:44:39 EDT 2016


Much needed series.

On Sat, Oct 8, 2016 at 2:40 PM, Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1475930199 14400
> #      Sat Oct 08 08:36:39 2016 -0400
> # Node ID 6034bb7c1e0cb80cae6f3f7d3058a456f9b49c5b
> # Parent  53708ce020c58f25079ef7b3802c71308843c0b4
> util: ensure forwarded attrs are set in globals() as sysstr
>
> Custom module importer strikes again.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -60,7 +60,8 @@ for attr in (
>      'socketserver',
>      'xmlrpclib',
>  ):
> -    globals()[attr] = getattr(pycompat, attr)
> +    a = pycompat.sysstr(attr)
> +    globals()[a] = getattr(pycompat, a)
>
>  # This line is to make pyflakes happy:
>  urlreq = pycompat.urlreq
> 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
> @@ -16,83 +16,73 @@
>    $ hg files 'set:(**.py) - grep(pygments)' | sed 's|\\|/|g' \
>    > | xargs $PYTHON3 contrib/check-py3-compat.py \
>    > | sed 's/[0-9][0-9]*)$/*)/'
> -  hgext/automv.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/blackbox.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/bugzilla.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/censor.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/chgserver.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/children.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/churn.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/clonebundles.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/color.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/automv.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/blackbox.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/bugzilla.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/censor.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/chgserver.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/children.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/churn.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/clonebundles.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/color.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/convert/bzr.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
> -  hgext/convert/common.py: error importing module: <AttributeError> module 'mercurial.util' has no attribute 'pickle' (line *)
> -  hgext/convert/convcmd.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> +  hgext/convert/convcmd.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/convert/cvs.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
> -  hgext/convert/cvsps.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/convert/cvsps.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/convert/darcs.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
>    hgext/convert/filemap.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
>    hgext/convert/git.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
>    hgext/convert/gnuarch.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
> -  hgext/convert/hg.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/convert/hg.py: error importing: <TypeError> can't concat bytes to str (error at filemerge.py:*)
>    hgext/convert/monotone.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
>    hgext/convert/p4.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
>    hgext/convert/subversion.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line *)
>    hgext/convert/transport.py: error importing module: <ImportError> No module named 'svn.client' (line *)
> -  hgext/eol.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/extdiff.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/factotum.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/fetch.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/eol.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/extdiff.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/fetch.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/fsmonitor/watchmanclient.py: error importing module: <SystemError> Parent module 'hgext.fsmonitor' not loaded, cannot perform relative import (line *)
> -  hgext/gpg.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/graphlog.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/hgk.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/histedit.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/journal.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/keyword.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'httpserver' (error at common.py:*)
> +  hgext/gpg.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/graphlog.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/hgk.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/histedit.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/journal.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/keyword.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/largefiles/basestore.py: error importing module: <SystemError> Parent module 'hgext.largefiles' not loaded, cannot perform relative import (line *)
> -  hgext/largefiles/lfcommands.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/largefiles/lfutil.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> +  hgext/largefiles/lfcommands.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/largefiles/localstore.py: error importing module: <SystemError> Parent module 'hgext.largefiles' not loaded, cannot perform relative import (line *)
> -  hgext/largefiles/overrides.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/largefiles/proto.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/largefiles/remotestore.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/largefiles/reposetup.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/largefiles/storefactory.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/largefiles/uisetup.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'httpserver' (error at common.py:*)
> +  hgext/largefiles/overrides.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/largefiles/proto.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/largefiles/remotestore.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/largefiles/reposetup.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/largefiles/storefactory.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/largefiles/uisetup.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    hgext/largefiles/wirestore.py: error importing module: <SystemError> Parent module 'hgext.largefiles' not loaded, cannot perform relative import (line *)
> -  hgext/mq.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/notify.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/pager.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/patchbomb.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/purge.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/rebase.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/record.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/relink.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/schemes.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/share.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/shelve.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  hgext/strip.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  hgext/transplant.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/archival.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/bundle2.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/bundlerepo.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/byterange.py: error importing module: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (line *)
> -  mercurial/changelog.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/cmdutil.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/commands.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/context.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/crecord.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/dispatch.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  hgext/mq.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/notify.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/pager.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/patchbomb.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/purge.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/rebase.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/record.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/relink.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/schemes.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/share.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/shelve.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/strip.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  hgext/transplant.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/archival.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/bundlerepo.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/cmdutil.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/commands.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/context.py: error importing: <TypeError> can't concat bytes to str (error at filemerge.py:*)
> +  mercurial/dispatch.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    mercurial/encoding.py: error importing module: <TypeError> bytes expected, not str (line *)
> -  mercurial/exchange.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/extensions.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/filelog.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/filemerge.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/fileset.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/formatter.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/help.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/hg.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> +  mercurial/exchange.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/extensions.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/fileset.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/help.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/hg.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    mercurial/hgweb/common.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *)
>    mercurial/hgweb/hgweb_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *)
>    mercurial/hgweb/hgwebdir_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *)
> @@ -102,36 +92,25 @@
>    mercurial/hgweb/webcommands.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *)
>    mercurial/hgweb/webutil.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *)
>    mercurial/hgweb/wsgicgi.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *)
> -  mercurial/hook.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/httpconnection.py: error importing module: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (line *)
> -  mercurial/httppeer.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> +  mercurial/hook.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/httppeer.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    mercurial/i18n.py: error importing module: <TypeError> bytes expected, not str (line *)
> -  mercurial/keepalive.py: error importing module: <AttributeError> module 'mercurial.util' has no attribute 'httplib' (line *)
> -  mercurial/localrepo.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/manifest.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/merge.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/namespaces.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/patch.py: error importing module: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (line *)
> +  mercurial/localrepo.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
> +  mercurial/merge.py: error importing: <TypeError> ord() expected string of length 1, but int found (error at store.py:*)
>    mercurial/pvec.py: error importing module: <NameError> name 'xrange' is not defined (line *)
> -  mercurial/repair.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/revlog.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> +  mercurial/repair.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
>    mercurial/revset.py: error importing module: <AttributeError> 'dict' object has no attribute 'iteritems' (line *)
>    mercurial/scmwindows.py: error importing module: <ImportError> No module named 'winreg' (line *)
> -  mercurial/sshpeer.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> -  mercurial/sshserver.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/statichttprepo.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at byterange.py:*)
> +  mercurial/sshpeer.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
> +  mercurial/sshserver.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
> +  mercurial/statichttprepo.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
>    mercurial/store.py: error importing module: <NameError> name 'xrange' is not defined (line *)
>    mercurial/streamclone.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
> -  mercurial/subrepo.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/templatefilters.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/templatekw.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/templater.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/ui.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/unionrepo.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'stringio' (error at patch.py:*)
> -  mercurial/url.py: error importing: <AttributeError> module 'mercurial.util' has no attribute 'urlerr' (error at httpconnection.py:*)
> +  mercurial/subrepo.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
> +  mercurial/unionrepo.py: error importing: <TypeError> can't concat bytes to str (error at store.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: <TypeError> %b requires bytes, or an object that implements __bytes__, not 'str' (error at bundle2.py:*)
> +  mercurial/wireproto.py: error importing: <TypeError> can't concat bytes to str (error at store.py:*)
>
>  #endif
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list