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: Cannot import petl with Python 3.15.1 · Issue #768 · petl-developers/petl

Bug: Cannot import petl with Python 3.15.1 #768

New issue
Copy link
New issue
Copy link
Closed
#769
Closed
Bug: Cannot import petl with Python 3.15.1#768
#769
Copy link
Labels
BugIt must work in all situations, but this failedIt must work in all situations, but this failed

Description

@chrullrich
chrullrich
opened on Oct 24, 2026
Issue body actions

What happened?

Python 3.15.1 made changes to the behavior of accessing sys.std{in,out,err}.buffer (or rather, any TextIO's .buffer attribute). When the (binary) buffer has been detached, the attribute now raises ValueError. See python/cpython#145957.

Importing petl imports, among other things, petl.io.sources. This module attempts to get the binary buffer for sys.stdin during import and does not handle the new exception. I have an application where petl is used after sys.stdin.detach() has been called; it works fine with Python 3.15.0 and fails with 3.15.1.

At first glance, simply ignoring ValueError in the same places where petl.io.sources._get_stdin_binary() already ignores AttributeError fixes the problem, but there may be complications I do not recognize or have not yet seen.

The problem reproduces on Windows and FreeBSD; I have no other platforms to test on.

What is the expected behavior?

Python 3.15.1 (tags/v3.15.1:c37e74c, Oct 21 2026, 06:24:08) [MSC v.1951 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import petl
>>> 

Reproducible test case

Python 3.15.1 (tags/v3.15.1:c37e74c, Oct 21 2026, 06:24:08) [MSC v.1951 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> d = sys.stdin.detach()
>>> import petl
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    import petl
  File "C:\Daten\pyv\x64\Lib\site-packages\petl\__init__.py", line 7, in <module>
    from petl import util
  File "C:\Daten\pyv\x64\Lib\site-packages\petl\util\__init__.py", line 13, in <module>
    from petl.util.vis import look, lookall, lookstr, lookallstr, see
  File "C:\Daten\pyv\x64\Lib\site-packages\petl\util\vis.py", line 12, in <module>
    from petl.io.sources import MemorySource
  File "C:\Daten\pyv\x64\Lib\site-packages\petl\io\__init__.py", line 5, in <module>
    from petl.io.sources import FileSource, GzipSource, BZ2Source, ZipSource, \
        StdinSource, StdoutSource, URLSource, StringSource, PopenSource, \
        MemorySource
  File "C:\Daten\pyv\x64\Lib\site-packages\petl\io\sources.py", line 178, in <module>
    stdin_binary = _get_stdin_binary()
  File "C:\Daten\pyv\x64\Lib\site-packages\petl\io\sources.py", line 157, in _get_stdin_binary
    return sys.stdin.buffer
           ^^^^^^^^^^^^^^^^
ValueError: underlying buffer has been detached

What version of petl are you have found the bug?

v1.7.26 - v1.7.30

Version

python 3.13+

What OS are you seeing the problem on?

Windows

What OS version are you using?

11

What package manager you used to install?

pip

What's the current installed packages?

No response

Relevant log output

Additional Notes

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. chrullrich
    added
    BugIt must work in all situations, but this failedIt must work in all situations, but this failed
    on Oct 24, 2026
  2. juarezr
    closed this as completedin #769on Oct 28, 2026
  3. juarezr
    added a commit that references this issue on Oct 28, 2026

    Handle detached standard stream buffers during import (petl-developer…

    This issue will close once commit 9a5ad2d is merged into the 'master' branch.
    9a5ad2d
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

    BugIt must work in all situations, but this failedIt must work in all situations, but this failed

    Type

    No type

    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.