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

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

Closed
mark-summerfield mannequin opened this issue Jun 25, 2008 · 2 comments
Closed

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

mark-summerfield mannequin opened this issue Jun 25, 2008 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@mark-summerfield
Copy link
Mannequin

mark-summerfield mannequin commented Jun 25, 2008

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']

@mark-summerfield
Copy link
Mannequin Author

mark-summerfield mannequin commented Jun 25, 2008

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.

@mark-summerfield mark-summerfield mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Jun 25, 2008
@amauryfa
Copy link
Member

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

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant