Skip to content

Silence pager stderr - #11864

Merged
Carreau merged 2 commits into
ipython:masterfrom
timokau:no-pager-stderr
Nov 21, 2019
Merged

Carreau merged 2 commits into
ipython:masterfrom
timokau:no-pager-stderr

Conversation

@timokau

@timokau timokau commented Aug 22, 2019

Copy link
Copy Markdown
Contributor

This is run as a test to determine if a pager is available. If there is
no pager, there is a fallback. Therefore, I think it is a bug that in
the no-pager case ipython will print

sh: less not found

To stderr.

I encountered this when running the sagemath testsuite on a machine without less and got surprised by the error messages.

This is run as a test to determine if a pager is available. If there is
no pager, there is a fallback. Therefore, I think it is a bug that in
the no-pager case ipython will print

 sh: less not found

To stderr.
Comment thread IPython/core/page.py Outdated
# if I use popen4, things hang. No idea why.
#pager,shell_out = os.popen4(pager_cmd)
pager = os.popen(pager_cmd, 'w')
pager = os.popen(pager_cmd + ' 2>/dev/null', 'w')

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.

Hum, wondering if we should use subprocess.Popen . Potentially subprocess.run now that this is available and properly discard stderr. I'm worried about string munging... but I may just be lazy and merge that as is later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't have enough experience with passing stdin to subprocess.Popen to be sure to cover all the edge-cases are covered in the same way they are covered now.

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.

I don't have enough experience with passing stdin to subprocess.Popen to be sure to cover all the edge-cases are covered in the same way they are covered now.

Then don't worry I'll push a commit on this branch if I decide subprocess.Popen is better.

Maybe not this week though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Friendly ping :)

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.

Yes sorry Aug/Sep/Oct were crazy with my team size at work decreasing by 33%... Slowly getting out of the tarpit.

This should in particular work on windows; as 2>/dev/null might not have
been proper windows syntax
@Carreau

Carreau commented Nov 17, 2019

Copy link
Copy Markdown
Member

I (finally) pushed some changes; would you mind having a look and let me know if that fixes your case ?

@Carreau Carreau added this to the 7.10 milestone Nov 17, 2019
Comment thread IPython/core/page.py
stdin=subprocess.PIPE,
stderr=subprocess.DEVNULL
)
pager = os._wrap_close(io.TextIOWrapper(proc.stdin), proc)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should we really use a function that is not part of the public API? What is the intention here?

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.

In this case I believe this is ok, as this is exactly what os.popen call. There is not much reason for it to change.

@timokau

timokau commented Nov 19, 2019

Copy link
Copy Markdown
Contributor Author

I can't reproduce the issue reliably, but since stderr is suppressed it should fix my issue.

@Carreau
Carreau merged commit 77d0855 into ipython:master Nov 21, 2019
@timokau
timokau deleted the no-pager-stderr branch November 23, 2019 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants