New GitHub issue #92670 from ayappanec:<br>
<hr>
<pre>
test_copyfile_nonexistent_dir fails in AIX.
======================================================================
FAIL: test_copyfile_nonexistent_dir (test.test_shutil.TestCopy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/python3_work/Python-3.9.12/Lib/test/test_shutil.py", line 1276, in test_copyfile_nonexistent_dir
self.assertRaises(FileNotFoundError, shutil.copyfile, src_file, dst)
AssertionError: FileNotFoundError not raised by copyfile
----------------------------------------------------------------------
>From the testcase.,
def test_copyfile_nonexistent_dir(self):
# Issue 43219
src_dir = self.mkdtemp()
src_file = os.path.join(src_dir, 'foo')
dst = os.path.join(src_dir, 'does_not_exist/')
write_file(src_file, 'foo')
self.assertRaises(FileNotFoundError, shutil.copyfile, src_file, dst)
It assumes that having a trailing slash ( 'does_not_exist/' ) makes the OS to consider it as directory. It is discussed more in this issue https://bugs.python.org/issue43219 . But in AIX, it is not the case. The trailing slash has no effect. It is considered as a file and get created. That is atleast how the AIX open call behaviour is.
import os
src_dir = 'temp_dir'
src_file = os.path.join(src_dir, 'foo')
dst = os.path.join(src_dir, 'does_not_exist/')
assert not os.path.exists(dst)
with open(dst, 'wb') as fp:
fp.write(b'foo')
Running the above in AIX, it creates the file does_not_exist.
The testcase is skipped for other distros like MacOS, Solaris because of different errors thrown. For AIX also, this testcase needs to be skipped , though for a different reason.
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/92670">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>