ValueError: I/O operation on closed file when .read uses on TextIOWrapper in Python 3.6

2

I am trying to read the stderr of the process for svn add command and seeing the mentioned error in Python 3.6 But The same code is working fine without errors in Python 2.7

Please find the code snippet from below:

try:
    if LoginEntry_Flag == True:
        cmd = ['svn','--no-auth-cache','--username', UserName, '--password', Password,"add", ProjectDirectory + "\*"]
    else:
        cmd = ['svn',"add", ProjectDirectory + "\*"]

    p1 = subprocess.Popen(cmd,
           stdin=subprocess.PIPE,
           stdout=subprocess.PIPE,
           stderr=subprocess.PIPE,
           universal_newlines=True,  # The universal_newlines argument is equivalent to text .By default, file objects are opened in binary mode.
           creationflags = 0x00000008
           )

    infile, outfile, errfile = p1.stdin, p1.stdout, p1.stderr
    p1.communicate()
    print (errfile.read())

except:
    print("Unexpected error during SVN ADD command/n",sys.exc_info())

And the Output is:

Unexpected error during SVN ADD command/n (<class 'ValueError'>, ValueError('I/O operation on closed file.',), <traceback object at 0x00000215640868C8>

I would appreciate if anyone can help me on this...Thank You In Advance..

python
asked on Stack Overflow Oct 28, 2019 by SowmyaPeddina

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0