A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20061103/e2c92bb2/attachment.html below:

<html><body>On 01:04 am, greg.ewing@canterbury.ac.nz wrote:<br />&gt;glyph@divmod.com wrote:<br /><br />&gt;If you're serious about writing platform-agnostic<br />&gt;pathname code, you don't put slashes in the arguments<br />&gt;at all. Instead you do<br />&gt;<br />&gt; &#160; os.path.join("hello", "slash", "world")<br />&gt;<br />&gt;Many of the other things you mention are also a<br />&gt;result of not treating pathnames as properly opaque<br />&gt;objects.<br /><br />Of course nobody who cares about these issues is going to put constant forward slashes into pathnames. &#160;The point is not that you'll forget you're supposed to be dealing with pathnames; the point is that you're going to get input from some source that you've got very little control over, and *especially* if that source is untrusted (although sometimes just due to mistakes) there are all kinds of ways it can trip you up. &#160;Did you accidentally pass it through something that doubles or undoubles all backslashes, etc. &#160;Sometimes these will result in harmless errors anyway, sometimes it's a critical error that will end up trying to delete /usr instead of /home/user/installer-build/ROOT/usr. &#160;If you have the path library catching these problems for you then a far greater percentage fall into the former category.<br /><br />&gt;If you're saying that the fact they're strings makes<br />&gt;it easy to forget that you're supposed to be treating<br />&gt;them opaquely,<br /><br />That's exactly what I'm saying.<br /><br />&gt;&gt; &#160;* although individual operations are atomic, shutil.copytree and friends <br />&gt;&gt;aren't. &#160;I've often seen python programs confused by partially-copied trees <br />&gt;&gt;of files.<br /><br />&gt;I can't see how this can be even remotely regarded<br />&gt;as a pathname issue, or even a filesystem interface<br />&gt;issue. It's no different to any other situation<br />&gt;where a piece of code can fall over and leave a<br />&gt;partial result behind.<br /><br />It is a bit of a stretch, I'll admit, but I included it because it is a weakness of the path library that it is difficult to do the kind of parallel iteration required to implement tree-copying yourself. &#160;If that were trivial, then you could write your own file-copying loop and cope with errors yourself.<br /></body></html>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4