mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Fix safe readlines: AttributeError: 'NoneType' object has no attribute 'readlines'
(#5646)
* fix * news * fix --------- Co-authored-by: a <1@1.1>
This commit is contained in:
parent
c0e0687376
commit
a1846d0579
2 changed files with 26 additions and 1 deletions
23
news/fix_safe_readlines.rst
Normal file
23
news/fix_safe_readlines.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Deprecated:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Removed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* Fixed exception "object has no attribute readlines" in case of redirect callable alias output.
|
||||||
|
|
||||||
|
**Security:**
|
||||||
|
|
||||||
|
* <news item>
|
|
@ -62,6 +62,8 @@ def SIGNAL_MESSAGES():
|
||||||
|
|
||||||
def safe_readlines(handle, hint=-1):
|
def safe_readlines(handle, hint=-1):
|
||||||
"""Attempts to read lines without throwing an error."""
|
"""Attempts to read lines without throwing an error."""
|
||||||
|
if handle is None:
|
||||||
|
return []
|
||||||
try:
|
try:
|
||||||
lines = handle.readlines(hint)
|
lines = handle.readlines(hint)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -276,7 +278,7 @@ class CommandPipeline:
|
||||||
lines = b.splitlines(keepends=True)
|
lines = b.splitlines(keepends=True)
|
||||||
yield from lines
|
yield from lines
|
||||||
self.end(tee_output=False)
|
self.end(tee_output=False)
|
||||||
elif self.captured == "stdout":
|
elif self.captured == "stdout" and stdout is not None:
|
||||||
b = stdout.read()
|
b = stdout.read()
|
||||||
s = self._decode_uninew(b, universal_newlines=True)
|
s = self._decode_uninew(b, universal_newlines=True)
|
||||||
self.lines = s.splitlines(keepends=True)
|
self.lines = s.splitlines(keepends=True)
|
||||||
|
|
Loading…
Add table
Reference in a new issue