Skip to content

doctest fails to display bytes type #48834

Closed

Description

@msyang
mannequin
BPO 4584
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2008-12-07.22:01:06.361>
created_at = <Date 2008-12-07.21:44:06.219>
labels = ['extension-modules', 'type-bug', 'invalid']
title = 'doctest fails to display bytes type'
updated_at = <Date 2008-12-07.22:01:06.344>
user = 'https://bugs.python.org/msyang'

bugs.python.org fields:

activity = <Date 2008-12-07.22:01:06.344>
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date = <Date 2008-12-07.22:01:06.361>
closer = 'georg.brandl'
components = ['Extension Modules']
creation = <Date 2008-12-07.21:44:06.219>
creator = 'msyang'
dependencies = []
files = []
hgrepos = []
issue_num = 4584
keywords = []
message_count = 2.0
messages = ['77264', '77268']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'msyang']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue4584'
versions = ['Python 3.0']

Activity

  1. msyang commented on Dec 7, 2008

    msyangmannequin
    MannequinAuthor

    doctest.testmod() fails when attempting to echo back a bytes type with
    ord() > 128.

    def ok():
       """
    >>> bytes([255,])
    b'\xff'

    """
    pass

    def notOK():
        """
    >>> b'\xff'

    """
    pass

    import doctest
    doctest.testmod()
    Traceback (most recent call last):
    ...
    UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in
    position 141: ordinal not in range(128)
  2. birkenfeld commented on Dec 7, 2008

    @birkenfeld
    Member

    You've included a chr(255) character in your docstring. You need to
    escape the backslash in order to include the bytes representation like
    it will be generated.

  3. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions