Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Py2] UnicodeDecodeError in doctest with Unicode #2434

Closed
inducer opened this issue May 25, 2017 · 4 comments
Closed

[Py2] UnicodeDecodeError in doctest with Unicode #2434

inducer opened this issue May 25, 2017 · 4 comments
Labels
type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously

Comments

@inducer
Copy link

inducer commented May 25, 2017

Save this file as x.rst:

.. doctest::

    >>> print(
    ...    "Hi\n\nByé")
    Hi
    ...
    Byé
    >>> 1/0
    1

Run with

python -m pytest x.rst 

on pytest 3.1.0 with Python 2.7.11, observe lengthy stacktrace ending with a UnicodeDecodeError in _ellipsis_match. Pytest 3.0.4 works fine.

@nicoddemus nicoddemus added type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously labels May 25, 2017
@nicoddemus
Copy link
Member

Thanks for the report and the reproducible example, we appreciate it.

@NiklasMM
Copy link
Contributor

NiklasMM commented Jun 13, 2017

I was still able to reproduce this issue in pytest 3.1.2 with the following file:

# -*- encoding: utf-8 -*-
from __future__ import unicode_literals

def fix_bad_unicode(text):
    """
        >>> print fix_bad_unicode('único')
        único
    """
    return "único"

Save as test.py and run python -m pytest --doctest-modules test.py. This results in an equally unpleasant stacktrace.
(Python 2.7.12, pytest 3.1.2)

For what it's worth: I made this file while debugging the same error generated by the file embedded in this blog post.

@nicoddemus
Copy link
Member

Indeed I can reproduce the problem using you example, thanks!

@inducer
Copy link
Author

inducer commented Dec 31, 2017

I don't have time to come up with another reproducer, but this issue is not entirely fixed: https://gitlab.tiker.net/inducer/loopy/-/jobs/40102.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

No branches or pull requests

3 participants