giampaolo / pyftpdlib

Extremely fast and scalable Python FTP server library
MIT License
1.65k stars 265 forks source link

Redecode homedir after os.path.realpath #594

Closed cielavenir closed 1 week ago

cielavenir commented 1 year ago

Because os.path.realpath can return bytes


issue: on Python2 this warning is printed even if the homedir argument is unicode:

  /opt/lib/python2.7/site-packages/pyftpdlib/handlers.py:2530: RuntimeWarning: DummyAuthorizerWithUnicodeHomeDir.get_home_dir returned a non-unicode string; now casting to unicode
    RuntimeWarning)
giampaolo commented 1 year ago

Because os.path.realpath can return bytes

Only if you pass bytes to it. If you pass a string it should return a string.

cielavenir commented 1 year ago

Please try to run this on both Python2 and Python3...

Maybe you would like realpath on _compat.py...

import os
dir = u'/'
realdir = os.path.realpath(dir)
print(type(dir) == type(realdir))
giampaolo commented 1 year ago

So the problem is on Python 2 only? What is the problem here exactly? You basically provided no description.

cielavenir commented 1 year ago

@giampaolo sorry added the original issue to the description

cielavenir commented 1 year ago

According to https://docs.python.org/2.7/whatsnew/2.3.html#pep-277-unicode-file-name-support-for-windows-nt , it seems this limitation is not applied to WinNT/macOS

giampaolo commented 1 week ago

Closing this out as I recently removed Python 2 support.