Skip to content

strings don't seem to roundtrip with repr()Β #47448

Closed

Description

@mark-summerfield
BPO 3198
Nosy @amauryfa, @mark-summerfield

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-06-25.13:51:06.726>
created_at = <Date 2008-06-25.13:33:50.544>
labels = ['interpreter-core', 'type-bug', 'invalid']
title = "strings don't seem to roundtrip with repr()"
updated_at = <Date 2008-06-25.13:51:06.718>
user = 'https://github.com/mark-summerfield'

bugs.python.org fields:

activity = <Date 2008-06-25.13:51:06.718>
actor = 'amaury.forgeotdarc'
assignee = 'none'
closed = True
closed_date = <Date 2008-06-25.13:51:06.726>
closer = 'amaury.forgeotdarc'
components = ['Interpreter Core']
creation = <Date 2008-06-25.13:33:50.544>
creator = 'mark'
dependencies = []
files = []
hgrepos = []
issue_num = 3198
keywords = []
message_count = 2.0
messages = ['68728', '68729']
nosy_count = 2.0
nosy_names = ['amaury.forgeotdarc', 'mark']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue3198'
versions = ['Python 2.5', 'Python 3.0']

Activity

  1. mark-summerfield commented on Jun 25, 2008

    mark-summerfieldmannequin
    MannequinAuthor

    With 2.5.2 and 30b1 strings don't round trip like numbers do.

    I guess it has been like this a long time so isn't a bug, but it does
    seem inconsistent.

    Both 2.5.2 and 30b1:

    >>> x = 5
    >>> x == int(repr(x))
    True
    >>> x = "Test Text"
    >>> x == str(repr(x))
    False

    The reason is that an extra set of enclosing quotes are added.

  2. amauryfa commented on Jun 25, 2008

    @amauryfa
    Contributor

    repr() is supposed to round-trip with eval() for common types.

    str() is the function that round-trips with the original type:

    >>> x = 5
    >>> x == int(str(x))
    True
    >>> x = "Test Text"
    >>> x == str(str(x))    #  :-)
    True
  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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions