GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use `write` instead of `stream.write` in `PrettyPrinter._pprint_frozendict` · Issue #145887 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Use write instead of stream.write in PrettyPrinter._pprint_frozendict#145887
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@devdanzin
devdanzin
opened on Mar 12, 2026
Issue body actions

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

  • gh-145887: Use write() instead of stream.write() in PrettyPrinter._pprint_frozendict #145894

Activity

  1. devdanzin
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Mar 12, 2026
  2. vstinner commented on Mar 12, 2026

    @vstinner
    vstinner
    on Mar 12, 2026
    Member
    More actions

    Ah right, write() should be used instead of stream.write.

    May I write the trivial PR?

    Sure, go ahead.

  3. vstinner
    added a commit that references this issue on Mar 13, 2026

    gh-145887: Use `write()` instead of `stream.write()` in `PrettyPrinte…

    0b6a234
  4. vstinner
    closed this as completedon Mar 13, 2026
  5. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-145887: Use `write()` instead of `stream.write()` in `Pretty…

    0cc673a
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/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.