Skip to content

Use write instead of stream.write in PrettyPrinter._pprint_frozendict #145887

Description

@devdanzin

Bug report

Bug description:

In the recent PR that added frozendict support to pprint (#144908), I let a small inconsistency get through: we set write = stream.write then immediately uses stream.write two lines below:

cpython/Lib/pprint.py

Lines 238 to 248 in cd52172

def _pprint_frozendict(self, object, stream, indent, allowance, context, level):
write = stream.write
cls = object.__class__
stream.write(cls.__name__ + '(')
length = len(object)
if length:
self._pprint_dict(object, stream,
indent + len(cls.__name__) + 1,
allowance + 1,
context, level)
write(')')

cc @vstinner. May I write the trivial PR?

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

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

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions