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

Comments

Projects
None yet
3 participants
@inducer

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

This comment has been minimized.

Member

nicoddemus commented May 25, 2017

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

nicoddemus added a commit to nicoddemus/pytest that referenced this issue May 25, 2017

nicoddemus added a commit to nicoddemus/pytest that referenced this issue May 26, 2017

@flub flub closed this in #2438 May 29, 2017

@NiklasMM

This comment has been minimized.

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

This comment has been minimized.

Member

nicoddemus commented Jun 13, 2017

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

@nicoddemus nicoddemus reopened this Jun 13, 2017

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Jun 13, 2017

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Jun 13, 2017

@inducer

This comment has been minimized.

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