1

my code :

import fcntl, os
import subprocess
p = subprocess.Popen(['bash'], bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
fcntl.fcntl(p.stdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
p.stdin.write( b'ls -l' + b'\n')
a=str(p.stdout.read().decode('utf-8'))
print(a)

perfect work in interpreter , but if i use : python3 myscript , i have this error :

a=str(p.stdout.read().decode('utf-8'))
AttributeError: 'NoneType' object has no attribute 'decode'

Why ? Thanks alot

sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • Hi Thomas Does this question help ? https://stackoverflow.com/questions/8949252/why-do-i-get-attributeerror-nonetype-object-has-no-attribute-something –  Jul 02 '19 at 19:04
  • 1
    Possible duplicate of [Why do I get AttributeError: 'NoneType' object has no attribute 'something'?](https://stackoverflow.com/questions/8949252/why-do-i-get-attributeerror-nonetype-object-has-no-attribute-something) –  Jul 02 '19 at 19:04
  • Hello , no my code perfect work in interpreter ! – thomas10_10 Jul 03 '19 at 17:13

0 Answers0