Skip to content

Improve Request.__repr__ #875

Closed
Closed
@sametmax

Description

Url can now contains unicode caracters, so:

def __repr__(self):
    return "<{} {} {} >".format(self.__class__.__name__,
                                self.method, self.path)

Will break as repr() expects ASCII chars.

To avoid this problem, use !r:

def __repr__(self):
    return "<{} {} {!r} >".format(self.__class__.__name__,
                                self.method, self.path)

You may also want to add the POST parameters in the repr to be even more debug friendly. This would however require to limit the number of keys displayed and their content in size.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions