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 — [Bug]: `io.StringIO()` checks `initial_value` before `newline`, raising `TypeError` instead of `ValueError` · Issue #1257 · oracle/graalpython

[Bug]: io.StringIO() checks initial_value before newline, raising TypeError instead of ValueError #1257

New issue
Copy link
New issue
Copy link
Open
#1268
Open
[Bug]: io.StringIO() checks initial_value before newline, raising TypeError instead of ValueError#1257
#1268
Copy link
Labels
bugSomething isn't workingSomething isn't working

Description

@jseop-lim
jseop-lim
opened on Oct 31, 2026
Issue body actions

Describe the bug

io.StringIO() type-checks initial_value before it validates newline. When both are invalid, GraalPy reports the initial_value error with TypeError, while CPython reports the illegal newline with ValueError.

Operating system

macOS

CPU architecture

ARM64

GraalPy version

master a3009f9 (Python 3.13.14); also reproduced on 25.1.3 (Python 3.12.8)

JDK version

No response

Context configuration

No response

Steps to reproduce

import io
io.StringIO(b'', 'x')

GraalPy master:

TypeError: StringIO() argument must be str, not bytes

Expected behavior

CPython 3.13.14 (same on 3.12.13):

ValueError: illegal newline value: 'x'

Stack trace

Additional context

io.StringIO(1, 'x') behaves the same way.

Root Cause

StringIOBuiltins.InitNode converts initial_value with the TString Argument Clinic conversion (StringIOBuiltins.java#L281-L293), which raises before the method body reaches validateNewline (#L318-L320). CPython's _io_StringIO___init___impl checks newline first and initial_value last (stringio.c#L670-L698).

Fix Suggestion

Take initial_value as a plain Object and convert it after validateNewline, raising initial_value must be str or None, not %p when it is not a str.

Activity

  1. jseop-lim
    added
    bugSomething isn't workingSomething isn't working
    on Oct 31, 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

    bugSomething isn't workingSomething isn't working

    Type

    No type

    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.