piranna / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

MountFS.mountfile doesn't work #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
... and I suspect it's never worked properly :(

What steps will reproduce the problem?
>>> from fs.mountfs import MountFS
>>> m = MountFS()
>>> m.mountfile('new.txt', lambda path, mode: open('testfile', mode))
>>> f = m.open('new.txt', 'w')

What is the expected output? What do you see instead?
I'd expect it to create a file named 'testfile', storing the filehandle in the 
variable named 'f'. Instead it throws an exception...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fs\base.py", line 144, in acquire_lock
    return func(self, *args, **kwargs)
  File "fs\mountfs.py", line 295, in open
    return callable(path, mode, **kwargs)
TypeError: callable() takes exactly one argument (2 given)

Please use labels and text to provide additional information.

The fact that this bug occurs suggests to me that the filemount code was never 
tested properly, since AFAICT it would never have worked.
So I'm going to commit an 'emergency patch' but I'll leave this bug open as I 
think some appropriate unit-tests ought to be added - I wonder what other 
FileMount-related bugs exist...

Original issue reported on code.google.com by gc...@loowis.durge.org on 17 Mar 2013 at 2:04

GoogleCodeExporter commented 9 years ago
Emergency patch is in r847 and I'm going to start a discussion thread about 
MountFile on the mailing list...

Original comment by gc...@loowis.durge.org on 17 Mar 2013 at 2:09

GoogleCodeExporter commented 9 years ago
"AFAICT it would never have worked" - confirmed. This bug has existed (in it's 
identical form) ever since MountFS.mountfile was added back in r32 !

Original comment by gc...@loowis.durge.org on 17 Mar 2013 at 2:23

GoogleCodeExporter commented 9 years ago
Patch looks good. I will have a look at some tests.

Original comment by willmcgugan on 17 Mar 2013 at 11:02

GoogleCodeExporter commented 9 years ago
Added some tests. Will close this issue as it seems to be working as intended 
now.

Original comment by willmcgugan on 17 Mar 2013 at 1:33