pyfilesystem
pyfilesystem copied to clipboard
open() renders "TypeError: setcontents() got an unexpected keyword argument 'errors'" exception
Using the open() method, I kept getting three variations of the same exception:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 761, in run
self.__target(*self.__args, **self.__kwargs)
File "/Users/dustin/development/python/mapreduce/mr/queue/message_handler.py", line 78, in wrapped_handler
handler(message_parameters)
File "/Users/dustin/development/python/mapreduce/mr/job_engine.py", line 440, in handle_map
path_type = next(handler_result_gen)
File "(lambda handler 'map_test_random_yield_grouped')", line 26, in a31aa26a8cccd50831f1e18a3d833cae30f7692b6
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/Users/dustin/development/python/mapreduce/mr/fs/general.py", line 166, in open
f = self.__fs.open(filepath, *args, **kwargs)
File "/Library/Python/2.7/site-packages/fs/remote.py", line 561, in open
f = super(CacheFSMixin, self).open(path, mode=mode, buffering=buffering, encoding=encoding, errors=errors, newline=newline, line_buffering=line_buffering, **kwargs)
File "/Library/Python/2.7/site-packages/fs/contrib/tahoelafs/__init__.py", line 86, in wrapper
return func(self, *args, **kwds)
File "/Library/Python/2.7/site-packages/fs/contrib/tahoelafs/__init__.py", line 160, in open
self.setcontents(path, b(''))
File "/Library/Python/2.7/site-packages/fs/remote.py", line 677, in setcontents
res = supsc(path, data, encoding=None, errors=None, chunk_size=chunk_size)
File "/Library/Python/2.7/site-packages/fs/contrib/tahoelafs/__init__.py", line 86, in wrapper
return func(self, *args, **kwds)
TypeError: setcontents() got an unexpected keyword argument 'errors'
I got exceptions for the "errors", "encoding", and "encodings" arguments being
unexpected.
This is the base definition:
def setcontents(self, path, file, chunk_size=64*1024):
This is the Tahoe definition:
def setcontents(self, path, file, chunk_size=64*1024):
This is a temporary version of the Tahoe definition that makes everything work
(though this arguments aren't being handled):
def setcontents(self, path, file, chunk_size=64*1024, errors=None, encoding=None, encodings=None):
Original issue reported on code.google.com by [email protected] on 17 Sep 2014 at 8:37
I should've been more clear that this error is specific to the Tahoe support.
Original comment by [email protected] on 17 Sep 2014 at 8:38
Where did "encodings" come from?
I've never used Tahoe (so can't test your fix) but it looks like you're correct
in that the setcontents prototype needs to be updated to match
http://docs.pyfilesystem.org/en/latest/base.html#fs.base.FS.setcontents
Original comment by [email protected] on 28 Oct 2014 at 2:50
The extra attributes came from the Python3 support. setcontents supports
unicode now. Unfortunately it changed the setcontents signature.
This fix is probably simple enough, but I don't know much about tahoefs myself.
Original comment by willmcgugan on 28 Oct 2014 at 3:07
- Changed state: Accepted
So who is going to be responsible for it? I have to make this change
whereever I use it.
Original comment by [email protected] on 28 Oct 2014 at 3:32
There is likely more to it than that change. Not sure when I'll have the time
to look at it. You could post to the mailing list, maybe the original author
can adapt it.
Original comment by willmcgugan on 28 Oct 2014 at 4:17