Skip to content

Log: Support formatting message with ascii in addition to repr #3164

Closed

Description

@pekkaklarck

Log keyword has supported formatting messages using repr() since RF 2.8.2 (#1584) by using repr=True argument. This is handy to detect special characters like the null byte, different Unicode normal forms (NFC vs. NFD), differences between Latin a and Cyrillic a, and so on.

In Python 2 repr() shows only visible ASCII characters as-is and others in escaped format like \xe4 for ä, but Python 3 changed repr() so that all normal characters are shown as-is. Python 3 approach has its benefits, but it also means it's not possible to see differences between characters that look the same but are actually different. Python 3 also added new ascii() built-in method that works like repr() in Python 2.

To make it possible to see what characters strings actually contain, we should enhance Log so that it can use ascii() in addition to repr(). One way would be adding new ascii=False argument, but I believe it's better to add separate formatter=str that can be configured to use repr or ascii (with ascii being same as repr in Python 2). We can use the same approach with Should Be Equal and other keywords that we plan to add this functionality (#2815). We should then later (probably in RF 3.2) deprecate the existing repr argument in favor of the new formatter argument.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions