[issue20056] Got deprecation warning when running test_shutil.py on Windows NT 6

Vajrasky Kok report at bugs.python.org
Tue Aug 5 16:46:48 CEST 2014


Vajrasky Kok added the comment:

Okay, here is the problem. In Windows, you get DeprecationWarning if you pass bytes object to method such as os.lstat.

foo.py
======
import os
os.lstat(b"C:\\Users\\vajrasky\\Code\\cpython\\python.bat")

C:\Users\vajrasky\Code\cpython>python.bat -Wdefault foo.py
foo.py:2: DeprecationWarning: The Windows bytes API has been deprecated, use Unicode filenames instead
  os.lstat(b"C:\\Users\\vajrasky\\Code\\cpython\\python.bat")

The test that throws this error is this one:

    def test_rmtree_works_on_bytes(self):
        tmp = self.mkdtemp()
        victim = os.path.join(tmp, 'killme')
        os.mkdir(victim)
        write_file(os.path.join(victim, 'somefile'), 'foo')
        victim = os.fsencode(victim)
        self.assertIsInstance(victim, bytes)
        shutil.rmtree(victim)  => This one calls os.lstat

So I am not sure how to fix this problem. Disable the test for Windows? If we convert the path to Unicode then the test losses the meaning.

----------
versions: +Python 3.5 -Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20056>
_______________________________________


More information about the Python-bugs-list mailing list