[Bug 5261] New: Importing mercurial module when locale is unitialized causes crash

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Mon Jun 6 15:17:48 UTC 2016


https://bz.mercurial-scm.org/show_bug.cgi?id=5261

            Bug ID: 5261
           Summary: Importing mercurial module when locale is unitialized
                    causes crash
           Product: Mercurial
           Version: 3.8.3
          Hardware: PC
                OS: Mac OS
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: Mercurial
          Assignee: bugzilla at selenic.com
          Reporter: nathan12343 at gmail.com
                CC: mercurial-devel at selenic.com

This came up in the context of a build system which imports mercurial to get
version information:

Traceback (most recent call last):
  File "create_config_info.py", line 62, in <module>
    changeset, branch, diff = get_hg_info()
  File "create_config_info.py", line 19, in get_hg_info
    from mercurial import hg, ui, commands 
  File
"/home/dudemcguy/local-yt-2015-09-08/yt-x86_64/lib/python2.7/site-packages/mercurial/hg.py",
line 13, in <module>
    import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo
  File
"/home/dudemcguy/local-yt-2015-09-08/yt-x86_64/lib/python2.7/site-packages/mercurial/localrepo.py",
line 10, in <module>
    import peer, changegroup, subrepo, pushkey, obsolete, repoview
  File
"/home/dudemcguy/local-yt-2015-09-08/yt-x86_64/lib/python2.7/site-packages/mercurial/subrepo.py",
line 13, in <module>
    import config, util, node, error, cmdutil, scmutil, match as matchmod
  File
"/home/dudemcguy/local-yt-2015-09-08/yt-x86_64/lib/python2.7/site-packages/mercurial/cmdutil.py",
line 17, in <module>
    import crecord as crecordmod
  File
"/home/dudemcguy/local-yt-2015-09-08/yt-x86_64/lib/python2.7/site-packages/mercurial/crecord.py",
line 19, in <module>
    locale.setlocale(locale.LC_ALL, '')
  File "/home/dudemcguy/local-yt-2015-09-08/yt-x86_64/lib/python2.7/locale.py",
line 579, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Apparently this is identical to issue 3575 in pip:
https://github.com/pypa/pip/issues/3575

There the fix was to wrap the call to locale.setlocale in a try/except block:

https://github.com/pypa/pip/pull/3598/commits/16f4cc3387a9d92c860c91a19b27cb4ab72e68f5

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list