[Don't Merge] Debug str repr alternatives#1397
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This offers two alternatives to #1393. The solution there was to restrict string repr to strictly the string types, excluding subclasses. Making a separate PR for discussion, if we decide on one of these I'll add it to the original PR.
5685cd6 adds "Markup(" as a recognized prefix. The debugger will remove it and not append it, since it will be handled by the subclass info. The downside is that this doesn't really solve the issue, any other string subclasses that have a non-standard repr will still look weird.
76320cb takes a different approach. Rather than truncating the obj then taking the repr, it truncates the repr. Then it only adds subclass info if the start of the repr looks like Python's standard repr, with the assumption that a non-standard prefix already distinguishes the subclass.
Both options add support for the Python 3 "b" prefix.