mostawesomedude / betterpath Goto Github PK
View Code? Open in Web Editor NEWA library for annoying people.
License: Other
A library for annoying people.
License: Other
It seems that the FilePath
you get by calling temporarySibling()
can only be used once. I discovered this while trying to use that as a way to download a file into a temporary name, then rename it into the final destination name so that other programs reading that file would see either the old or new contents, not an intermediate state (since moveTo()
tries very hard to be atomic).
Here's a small script which demonstrates the bug:
from bp.filepath import FilePath
path = FilePath("/tmp/whatever")
tmp = path.temporarySibling()
with tmp.open("w") as fp:
fp.write("Hello, world\n")
with tmp.open("r") as fp:
print fp.read()
Which results in the following error:
Traceback (most recent call last):
File "betterpath_bug.py", line 8, in <module>
with tmp.open("r") as fp:
File "/Users/dcrosta/.../bp/filepath.py", line 438, in open
return self.create()
File "/Users/dcrosta/.../bp/filepath.py", line 1012, in create
fdint = os.open(self.path, _CREATE_FLAGS)
OSError: [Errno 17] File exists: '/tmp/EfvvV6szVDBZfPlkwhatever'
In the traceback you can see it's calling create()
even though I'm trying to do a read operation?
You get the same error if you try to re-open the file with mode "w", too.
Can I coax you into another release (containing the context manager for MemoryFile)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.