#165 Declined
Repository
birkenfeld birkenfeld
Branch
default

Fix "path_stabilize" with byte strings.

Author
  1. Matt Good avatarMatt Good
Reviewers
Description

Fix "path_stabilize" with byte strings.

Comments (5)

  1. Matt Good author

    My current projects using Sphinx fail to build with 1.2b2. The "path_stabilize" function throws a TypeError when given a "bytes" string instead of unicode. The unicode normalization only needs run on unicode strings, so this skips it for "bytes" strings.

    File ".../sphinx/sphinx/util/__init__.py", line 57, in path_stabilize
        newpath = unicodedata.normalize('NFC', newpath)
    TypeError: normalize() argument 2 must be unicode, not str
    
  2. Matt Good author

    For the full error:

    $ python setup.py build_sphinx
    running build_sphinx
    Running Sphinx v1.2b2
    loading pickled environment... done
    building [html]: targets for 0 source files that are out of date
    updating environment: Traceback (most recent call last):
      File "setup.py", line 41, in <module>
        'Programming Language :: Python',
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 975, in run_commands
        self.run_command(cmd)
      File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/dist.py", line 995, in run_command
        cmd_obj.run()
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/setup_command.py", line 143, in run
        app.build(force_all=self.all_files)
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/application.py", line 212, in build
        self.builder.build_update()
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/builders/__init__.py", line 214, in build_update
        'out of date' % len(to_build))
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/builders/__init__.py", line 231, in build
        self.doctreedir, self.app)
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/environment.py", line 440, in update
        self.find_files(config)
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/environment.py", line 345, in find_files
        self.srcdir, config.source_suffix, exclude_matchers=matchers))
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/util/__init__.py", line 94, in get_matching_docs
        for filename in get_matching_files(dirname, exclude_matchers):
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/util/__init__.py", line 78, in get_matching_files
        qdirs = [entry for entry in qdirs if not matcher(entry[1])]
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/util/__init__.py", line 74, in <genexpr>
        for dn in dirs)
      File "/Users/mgood/Projects/lerna/.tox/lerna/src/sphinx/sphinx/util/__init__.py", line 57, in path_stabilize
        newpath = unicodedata.normalize('NFC', newpath)
    TypeError: normalize() argument 2 must be unicode, not str
    
  3. Matt Good author

    I'd considered checking for "unicode", but I flipped it around because that's not compatible with Python 3, which I assume Sphinx is supporting based on the "pycompat" module. I only tested the "bytes" type-check on Python 2, but it should also work the same way on Python 3.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.