On 11/13/18 6:03 PM, Richard Purdie wrote:
On Tue, 2018-11-13 at 17:04 +0800, [email protected] wrote:
From: Changqing Li <[email protected]>

fix below problem:
pydevshell raises exception when maximize the python shell window.
when click maximize, rlist of select return ready object, but the
pty.read is None, so throw exception of 'NoneType' object has no
attribute 'decode', change to only decode when readdata is valid.

[YOCTO #11875]

Signed-off-by: Changqing Li <[email protected]>
---
  scripts/oepydevshell-internal.py | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/oepydevshell-internal.py b/scripts/oepydevshell-
internal.py
index 04621ae..2d1bc77 100755
--- a/scripts/oepydevshell-internal.py
+++ b/scripts/oepydevshell-internal.py
@@ -63,7 +63,10 @@ try:
              (ready, _, _) = select.select([pty, sys.stdin], writers
, [], 0)
              try:
                  if pty in ready:
-                    i = i + pty.read().decode('utf-8')
+                    readdata=pty.read()
+                    if readdata == None:
+                        continue
+                    i = i + readdata.decode('utf-8')
Usually you'd write this as:

if readdata:
     i = i + readdata.decode('utf-8')

Is there a reason not to do that here?

If you really want to test for None, you usually write:

if readdata is None:

which is a little more pythonic.

Cheers,

Richard

Thanks. I will correct the patch as suggested.

//Changqing

--
BRs

Sandy(Li Changqing)

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to