Skip to content

Raise an error when attempting to close stdio or stderr - #4480

Open
d-torrance wants to merge 1 commit into
Macaulay2:developmentfrom
d-torrance:close
Open

Raise an error when attempting to close stdio or stderr#4480
d-torrance wants to merge 1 commit into
Macaulay2:developmentfrom
d-torrance:close

Conversation

@d-torrance

@d-torrance d-torrance commented Jul 19, 2026

Copy link
Copy Markdown
Member

stdio supports both input and output, so we check in both closeIn and closeOut

stderr only supports output, so we only check in closeOut (stderr << closeIn already raises an error since it's not open for input)

Closes: #4392

No AI used!

Before

i1 : stdio << close
stdio:1:6:(3):[1]: error: at print: expected an output file
stdio:1:6:(3):[1]: error: after print: expected an output file
i1 : stderr << close

o1 = stderr

o1 : File

i2 : 1/0

i3 : -- where's the error message?

After

i1 : stdio << close
stdio:1:6:(3):[1]: error: can't close stdio

i2 : stderr << close
stdio:2:7:(3):[1]: error: can't close stderr

stdio supports both input and output, so we check in both closeIn and
closeOut

stderr only supports output, so we only check in closeOut (stderr <<
closeIn already raises an error since it's not open for input)
@d-torrance d-torrance linked an issue Jul 19, 2026 that may be closed by this pull request

@MichaelABurr MichaelABurr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple, and looks OK to me. I don't expect this code to be encountered frequently, so I don't expect a performance hit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

closing stdio breaks M2

2 participants