(original) (raw)

On Sat, Dec 4, 2010 at 20:04, hirokazu.yamamoto <python-checkins@python.org> wrote:
Author: hirokazu.yamamoto
Date: Sun Dec �5 03:04:16 2010
New Revision: 87070

Log:
Now can reproduce the error on AMD64 Windows Server 2008
even where os.symlink is not supported.


Modified:
� python/branches/py3k/Lib/test/test\_shutil.py

Modified: python/branches/py3k/Lib/test/test\_shutil.py
\==============================================================================
\--- python/branches/py3k/Lib/test/test\_shutil.py � � � �(original)
+++ python/branches/py3k/Lib/test/test\_shutil.py � � � �Sun Dec �5 03:04:16 2010
@@ -271,25 +271,33 @@
� � � � � � shutil.rmtree(src\_dir)
� � � � � � shutil.rmtree(os.path.dirname(dst\_dir))

\- � �@unittest.skipUnless(hasattr(os, "symlink"),
\- � � � � � � � � � � � � "Missing symlink implementation")
\+ � �@unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
� � def test\_dont\_copy\_file\_onto\_link\_to\_itself(self):
� � � � # bug 851123.
� � � � os.mkdir(TESTFN)
� � � � src = os.path.join(TESTFN, 'cheese')
� � � � dst = os.path.join(TESTFN, 'shop')
� � � � try:
\- � � � � � �f = open(src, 'w')
\- � � � � � �f.write('cheddar')
\- � � � � � �f.close()
\-
\- � � � � � �if hasattr(os, "link"):
\- � � � � � � � �os.link(src, dst)
\- � � � � � � � �self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
\- � � � � � � � �with open(src, 'r') as f:
\- � � � � � � � � � �self.assertEqual(f.read(), 'cheddar')
\- � � � � � � � �os.remove(dst)
\+ � � � � � �with open(src, 'w') as f:
\+ � � � � � � � �f.write('cheddar')
\+ � � � � � �os.link(src, dst)
\+ � � � � � �self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
\+ � � � � � �with open(src, 'r') as f:
\+ � � � � � � � �self.assertEqual(f.read(), 'cheddar')
\+ � � � � � �os.remove(dst)
\+ � � � �finally:
\+ � � � � � �shutil.rmtree(TESTFN, ignore\_errors=True)

\+ � �@unittest.skipUnless(hasattr(os, "symlink"),
\+ � � � � � � � � � � � � "Missing symlink implementation")
\+ � �def test\_dont\_copy\_file\_onto\_symlink\_to\_itself(self):
\+ � � � �# bug 851123.
\+ � � � �os.mkdir(TESTFN)
\+ � � � �src = os.path.join(TESTFN, 'cheese')
\+ � � � �dst = os.path.join(TESTFN, 'shop')
\+ � � � �try:
\+ � � � � � �with open(src, 'w') as f:
\+ � � � � � � � �f.write('cheddar')
� � � � � � # Using \`src\` here would mean we end up with a symlink pointing
� � � � � � # to TESTFN/TESTFN/cheese, while it should point at
� � � � � � # TESTFN/cheese.
@@ -299,10 +307,7 @@
� � � � � � � � self.assertEqual(f.read(), 'cheddar')
� � � � � � os.remove(dst)
� � � � finally:
\- � � � � � �try:
\- � � � � � � � �shutil.rmtree(TESTFN)
\- � � � � � �except OSError:
\- � � � � � � � �pass
\+ � � � � � �shutil.rmtree(TESTFN, ignore\_errors=True)

� � @unittest.skipUnless(hasattr(os, "symlink"),
� � � � � � � � � � � � �"Missing symlink implementation")
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-checkins mailing list
Python-checkins@python.org
http://mail.python.org/mailman/listinfo/python-checkins

I created #10540 for this issue, but the patch I have on there is just a bad hack. I need to fix os.path.samefile for hard links, which might be easier if we keep st\_ino data in stat structures on Windows.