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 — Windows cpXXX codecs: StreamReader raises TypeError (decode() missing 'final') · Issue #158980 · python/cpython

Windows cpXXX codecs: StreamReader raises TypeError (decode() missing 'final') #158980

New issue
Copy link
New issue
Copy link
Open
Open
Windows cpXXX codecs: StreamReader raises TypeError (decode() missing 'final')#158980
Copy link
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesOS-windowstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sricursion
sricursion
opened on Oct 7, 2026
Issue body actions

Bug report

Bug description:

Since 3.14 (gh-123803), the cpXXX codecs for the Windows code pages that have no module of their own in encodings are provided by encodings._win_cp_codecs. Their stream reader cannot read anything:

import codecs, io

text = 'привет'
reader = codecs.getreader('cp20866')(io.BytesIO(text.encode('cp20866')))
print(reader.read() == text)

Output:

Traceback (most recent call last):
  File "repro.py", line 5, in <module>
    print(reader.read() == text)
          ~~~~~~~~~~~^^
  File ".../Lib/codecs.py", line 512, in read
    newchars, decodedbytes = self.decode(data, self.errors)
                             ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
TypeError: create_win32_code_page_codec.<locals>.StreamReader.decode() missing 1 required positional argument: 'final'

Expected output: True.

readline() and codecs.StreamReaderWriter.read() fail in the same way. codecs.iterdecode() and io.TextIOWrapper work, because they use the incremental decoder.

codecs.StreamReader.read() calls self.decode(data, self.errors), but StreamReader.decode() in Lib/encodings/_win_cp_codecs.py is defined as decode(self, input, errors, final), so final is required. It should be optional and default to False (as for encodings.mbcs), so that an incomplete multibyte sequence is kept until the next read.

CPython versions tested on:

CPython main branch (the 3.14 and 3.15 branches contain the same code)

Operating systems tested on:

Windows

Linked PRs

  • gh-158980: Fix StreamReader.decode() of the Windows cpXXX codecs #158990

Activity

  1. aisk
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    OS-windows
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    3.16new features, bugs and security fixesnew features, bugs and security fixes
    on Oct 8, 2026
  2. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 2026
  3. github-project-automation
    moved this to Todo in Project_VKon Oct 18, 2026
  4. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 2026
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

    3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesOS-windowstype-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 01402503 — 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.