From: Fernando P. <Fer...@co...> - 2005-10-10 18:18:34
|
Joost van Evert wrote: > Dear list, > /usr/local/lib/python2.4/site-packages/matplotlib/texmanager.py > in make_dvi(self, tex, force) > 125 # dir and move it if necessary and then cleanup > 126 if os.path.exists(dvibase): > --> 127 os.rename(dvibase, dvifile) > 128 for fname in glob.glob(prefix+'*'): > 129 os.remove(fname) > > OSError: [Errno 18] Invalid cross-device link This could be considered a matplolib bug, or a python one, depending on your perspective. os.rename() doesn't work across partitions, which makes it (IMHO) worse than useless. You have to either protect on all uses against this exception, or use shutil.move(), which does work across partitions: Definition: shutil.move(src, dst) Docstring: Recursively move a file or directory to another location. If the destination is on our current filesystem, then simply use rename. Otherwise, copy src to the dst and then remove src. A lot more could be done here... A look at a mv.c shows a lot of the issues this implementation glosses over. So if you think that Python is OK in having such a useless os.rename, then it's a matplotlib bug (this is, after all, known os.rename behavior). In the short term, though, matplotlib would be well advised to use only os.rename when doing renamings *known to be in the same directory*. Anytime you use rename to actually move things, this problem can appear (and it's configuration-specific, hence impossible to detect during in-house testing). Cheers, f |