Bug 1498084 - ImportError: cannot import name normalize
Summary: ImportError: cannot import name normalize
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-sphinx
Version: 26
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-03 13:11 UTC by Christian Stadelmann
Modified: 2017-11-14 19:23 UTC (History)
16 users (show)

Fixed In Version: python-sphinx-1.5.5-1.fc26
Clone Of:
Environment:
Last Closed: 2017-11-14 19:23:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Christian Stadelmann 2017-10-03 13:11:14 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Open an empty directory
2. run `$ python2 -msphinx -M html . _build`
3. watch output

Actual results:
Fails in gettext (which is part of python2-libs and thus the python2 package) with this traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sphinx/__main__.py", line 14, in <module>
    sys.exit(main(sys.argv))
  File "/usr/lib/python2.7/site-packages/sphinx/__init__.py", line 66, in main
    sys.exit(build_main(argv))
  File "/usr/lib/python2.7/site-packages/sphinx/__init__.py", line 76, in build_main
    from sphinx import cmdline
  File "/usr/lib/python2.7/site-packages/sphinx/cmdline.py", line 14, in <module>
    import optparse
  File "/usr/lib64/python2.7/optparse.py", line 419, in <module>
    _builtin_cvt = { "int" : (_parse_int, _("integer")),
  File "/usr/lib64/python2.7/gettext.py", line 644, in gettext
    return dgettext(_current_domain, message)
  File "/usr/lib64/python2.7/gettext.py", line 608, in dgettext
    codeset=_localecodesets.get(domain))
  File "/usr/lib64/python2.7/gettext.py", line 543, in translation
    mofiles = find(domain, localedir, languages, all=1)
  File "/usr/lib64/python2.7/gettext.py", line 515, in find
    for nelang in _expand_lang(lang):
  File "/usr/lib64/python2.7/gettext.py", line 206, in _expand_lang
    from locale import normalize
ImportError: cannot import name normalize


Expected results:
No traceback. If python2-libs requires a module, it must either provide the module itself, have a Requires: on a package providing this module or provide a fallback to work without that module.

Additional info:
python2-libs-2.7.13-12.fc26.x86_64

Comment 1 Petr Viktorin (pviktori) 2017-10-04 08:46:10 UTC
That's weird -- both the gettext and locale modules should be provided by python2-libs.

To debug, could run these commands and post the output here?

    rpm --verify python2-libs
    python2 -c 'import locale; print(locale)'
    python2 -c 'import sys; print(sys.path)'

Comment 2 Miro Hrončok 2017-10-04 14:18:32 UTC
Also, is this reproducible on your system with just:

    $ python2 -c 'from locale import normalize'

?

Comment 3 Christian Stadelmann 2017-10-04 19:38:40 UTC
(In reply to Petr Viktorin from comment #1)
> […]

$ rpm --verify python2-libs
$ echo $?
0

$ python2 -c 'import locale; print(locale)'
<module 'locale' from '/usr/lib64/python2.7/locale.pyc'>
$ echo $?
0

$ python2 -c 'import sys; print(sys.path)'['', '/usr/lib/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/home/username/.local/lib/python2.7/site-packages', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
$ echo $?
0

(In reply to Miro Hrončok from comment #2)
> Also, is this reproducible on your system with just:

$ python2 -c 'from locale import normalize'
$ echo $?
0

Comment 4 Miro Hrončok 2017-10-05 09:59:41 UTC
Is the pwd truly empty when you run step 2? I can only reproduce this by creating a fake (i.e. empty) locale module in pwd. (You clearly said it's an empty directory, I'm just trying to be double sure.)

Comment 5 Christian Stadelmann 2017-10-05 10:16:14 UTC
(In reply to Miro Hrončok from comment #4)
> Is the pwd truly empty when you run step 2? I can only reproduce this by
> creating a fake (i.e. empty) locale module in pwd. (You clearly said it's an
> empty directory, I'm just trying to be double sure.)

It doesn't matter whether pwd is empty in this step or not, I'm getting the same backtrace in either case. I just wrote that the directory should be empty to make the steps easier to reproduce.

Comment 6 Christian Stadelmann 2017-10-31 16:03:35 UTC
Could any of you reproduce the backtrace with the steps in comment #0?

This issue is also affecting python3-sphinx, i.e. it can also be reproduced by executing

$ python3 -msphinx -M html . _build

in an empty directory, so it might be a bug in sphinx too. Because of that, I'm adding the sphinx maintainers too.

Comment 7 Christian Stadelmann 2017-10-31 16:07:44 UTC
Note that I can't reproduce this issue on a different machine with Fedora 27 installed, but otherwise very similar setup.

Comment 8 Petr Viktorin (pviktori) 2017-10-31 16:36:08 UTC
Oh! I see now. And I can finally reproduce. Looks like a bug in Sphinx.

Sphinx has:
    /usr/lib/python2.7/site-packages/sphinx/locale/__init__.py
and in python2, when running "-m sphinx", importing "locale" from anywhere gives you Sphinx's locale package.

I'm not sure how to best fix this :(

Comment 9 Petr Viktorin (pviktori) 2017-10-31 16:37:43 UTC
Let me know if I can help from the Python side. The semantics of python2 are quite unfortunate.

Comment 10 Christian Stadelmann 2017-11-04 12:42:21 UTC
(In reply to Christian Stadelmann from comment #7)
> Note that I can't reproduce this issue on a different machine with Fedora 27
> installed, but otherwise very similar setup.

I think this issue has been fixed upstream already. Updating python-sphinx (see bug #1508237 for that) might be enough to get rid of this bug.

Comment 11 Christian Stadelmann 2017-11-05 14:14:38 UTC
The builds from `pip install --user sphinx` work fine too after uninstalling the python2-spinx package from Fedora 26.

Comment 12 Charalampos Stratakis 2017-11-06 11:14:20 UTC
(In reply to Christian Stadelmann from comment #10)
> (In reply to Christian Stadelmann from comment #7)
> > Note that I can't reproduce this issue on a different machine with Fedora 27
> > installed, but otherwise very similar setup.
> 
> I think this issue has been fixed upstream already. Updating python-sphinx
> (see bug #1508237 for that) might be enough to get rid of this bug.

Will take care of updating sphinx, however versions 1.6+ is only on F27+ since it introduces breaking changes.

F26 currently is on 1.5.2 while the current upstream version from that branch is 1.5.5. Christian would you be able to test the 1.5.5 version to see if the issue is fixed there?

If not I can try to bisect the issue and backport the fix to F26.

Comment 13 Charalampos Stratakis 2017-11-06 14:20:30 UTC
Tested it myself in a mock chroot and I was able to verify that the issue is indeed fixed by version 1.5.5. Will push an update.

Comment 14 Fedora Update System 2017-11-07 00:12:30 UTC
python-sphinx-1.5.5-1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-00050526e6

Comment 15 Fedora Update System 2017-11-14 19:23:13 UTC
python-sphinx-1.5.5-1.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.