[Python-modules-team] Bug#812672: Bug#812672: djangorestframework: FTBFS - TypeError: a bytes-like object is required, not 'str'

Brian May bam at debian.org
Mon Jan 25 23:42:53 UTC 2016


Michael Tautschnig <mt at debian.org> writes:

> During a rebuild of all Debian packages in a clean sid chroot (using cowbuilder
> and pbuilder) the build failed with the following error.

I am unable to reproduce this build failure. On clean Debian sid chroot.

> [...]
> # Build the HTML documentation.
> mkdir /srv/jenkins-slave/workspace/sid-goto-cc-djangorestframework/djangorestframework-3.3.2/docs.debian
> LANG=C.UTF-8 mkdocs build && mv site docs.debian/html
> Traceback (most recent call last):
>   File "/usr/bin/mkdocs", line 9, in <module>
>     load_entry_point('mkdocs==0.14.0', 'console_scripts', 'mkdocs')()
>   File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
>     return self.main(*args, **kwargs)
>   File "/usr/lib/python3/dist-packages/click/core.py", line 675, in main
>     _verify_python3_env()
>   File "/usr/lib/python3/dist-packages/click/_unicodefun.py", line 69, in _verify_python3_env
>     if locale.lower().endswith(('.utf-8', '.utf8')):
> TypeError: a bytes-like object is required, not 'str'
> debian/rules:12: recipe for target 'override_dh_auto_build' failed
> make[1]: *** [override_dh_auto_build] Error 1

Looks like a problem with python3-click, used by mkdocs.

>From my build log:

Get:42 http://localhost:9999/debian sid/main i386 python3-click all 6.2-1 [56.0 kB]
Get:51 http://localhost:9999/debian sid/main i386 mkdocs all 0.14.0-1 [270 kB]

The code in question is:

    if os.name == 'posix':
        import subprocess
        rv = subprocess.Popen(['locale', '-a'], stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE).communicate()[0]
        good_locales = set()
        has_c_utf8 = False
        for line in rv.splitlines():
            locale = line.strip()
            if locale.lower().endswith(('.utf-8', '.utf8')):
                good_locales.add(locale)
                if locale.lower() in ('c.utf8', 'c.utf-8'):
                    has_c_utf8 = True

To me this code does look broken. line I think is a bytes object, so we
can't compare with str. I will have to try and work out why it isn't
crashing for me...

In any case I believe this is a bug in python3-click. Now, I can
reproduce it too, however not in the build of djangorestframework,
because it sets LANG:


(sid-amd64)root at prune:/home/brian# mkdocs 
Traceback (most recent call last):
  File "/usr/bin/mkdocs", line 9, in <module>
    load_entry_point('mkdocs==0.14.0', 'console_scripts', 'mkdocs')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 675, in main
    _verify_python3_env()
  File "/usr/lib/python3/dist-packages/click/_unicodefun.py", line 69, in _verify_python3_env
    if locale.lower().endswith(('.utf-8', '.utf8')):
TypeError: a bytes-like object is required, not 'str'


(sid-amd64)root at prune:/tmp/brian/tmp9rNvFP/build/amd64# LANG=C.UTF-8 mkdocs
Usage: mkdocs [OPTIONS] COMMAND [ARGS]...

  MkDocs - Project documentation with Markdown.

Options:
  -V, --version  Show the version and exit.
  -q, --quiet    Silence warnings
  -v, --verbose  Enable verbose output
  -h, --help     Show this message and exit.

Commands:
  build      Build the MkDocs documentation
  gh-deploy  Deply your documentation to GitHub Pages
  json       Build the MkDocs documentation to JSON files...
  new        Create a new MkDocs project
  serve      Run the builtin development server

-- 
Brian May <bam at debian.org>



More information about the Python-modules-team mailing list