pybind / pybind/pybind11

[BUG] py::print does not work when linking as a Windows application

Open
#2,749 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Hey folks, I'm not sure if this is intended behavior, but py::print does not work for me when building a Windows application in cmake, I get the error AttributeError: 'NoneType' object has no attribute 'write. However, things work fine when keeping everything identical and building as a console application.

I don't know why pybind11 prints to console happily but doesn't like the std::out in an MSVC windows application, but I thought I'd bring it up~

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior with py::print in the CMake-built Windows application and compare it with the console application case. Trace how py::print handles std::out under MSVC, then verify that output works in the Windows application without regressing console builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, python
Domain
backend-api-design, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.