PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
285 stars 63 forks source link

Update __init__.py #227

Closed travcunn closed 7 years ago

travcunn commented 8 years ago

Using OSFS.getsyspath("/diseño/test123") causes problems.

Here is a partial stack trace:

File "/usr/local/smartfile/virtualenv/lib/python2.7/site-packages/fs/osfs/__init__.py", line 246, in exists
   return _exists(self.getsyspath(path))
 File "/usr/local/smartfile/virtualenv/lib/python2.7/site-packages/fs/osfs/__init__.py", line 167, in getsyspath
   path = relpath(normpath(path)).replace(u"/", os.sep)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128)

Hopefully this pull request resolves this issue

willmcgugan commented 8 years ago

Is that a str on Python2.7?

That method takes FS paths, which should always be unicode. The fix may be to raise an error if its a bytes string.

travcunn commented 8 years ago

Good call. Yes it is a str on Python2.7.

arekbulski commented 8 years ago

I think this is resolved. Close it? Ping @lurch

lurch commented 8 years ago

This hasn't been resolved. "The fix may be to raise an error if its a bytes string." But if you want to create an issue instead @arekbulski (which would be more appropriate) then I'll close this PR (which contains an invalid fix).

willmcgugan commented 7 years ago

Going to close this one. Its a valid point though. fs2 it will raise an exception for any path that isn't unicode. I'd consider backporting it if there is demand...