Author: kmtracey Date: 2009-04-04 23:48:11 -0500 (Sat, 04 Apr 2009) New Revision: 10397
Modified: django/branches/releases/1.0.X/ django/branches/releases/1.0.X/django/core/files/move.py Log: Fixed #8900: Added errno=13 (permission denied) to the class of ignored OSErrors when attempting to delete the old file in file_move_safe. This error was seen on Windows with Pythons < 2.5. In the case where the error was seen, the old file is auto-deleted on close anyway by the Windows-specific NamedTemporaryFile support. No new test because the failure could be seen when running the file_uploads test with Python 2.3/2.4 on Windows. With this fix file_uploads runs clean in that environment. While in the neignborhood fixed up the docstrings to better match the reality of what the code does and what the function is named. r10396 from trunk. Property changes on: django/branches/releases/1.0.X ___________________________________________________________________ Name: svnmerge-integrated - /django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9526,9529,9533-9536,9539-9550,9556-9557,9559-9560,9562-9568,9570-9591,9595-9619,9621-9624,9626-9636,9638-9642,9644-9645,9647-9689,9691-9699,9703-9706,9709-9713,9716-9723,9725-9726,9730-9738,9740-9741,9750-9751,9757-9758,9761-9762,9767-9768,9770-9780,9782-9784,9789-9790,9793-9798,9801-9802,9806-9807,9809-9813,9821-9837,9842-9843,9847-9859,9861,9863-9875,9877-9881,9883-9887,9899-9903,9906-9909,9912,9914,9916-9917,9919-9920,9922-9927,9929,9931-9937,9939,9942-9943,9945-9950,9953-9954,9956-9962,9966-9977,9979-9984,9986-9988,9990-10001,10003-10004,10007,10009-10010,10013-10017,10019-10020,10022-10025,10031,10036-10041,10049-10052,10054-10061,10066-10069,10071-10076,10078-10079,10085-10087,10104,10106,10125-10127,10136,10138-10140,10143,10145-10147,10149-10160,10163-10167,10170,10173,10175-10176,10180,10185,10189,10192-10196,10198-10221,10223-10228,10230-10234,10236-10247,10250-10257,10259-10270,10273-10274,10276-10280,10282-10314,10316,10319-10322,10325,10328-10329,10333-10344,10348-10351,10354-10356,10358-10363,10365-10368,10371-10380,10386-10394 + /django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9526,9529,9533-9536,9539-9550,9556-9557,9559-9560,9562-9568,9570-9591,9595-9619,9621-9624,9626-9636,9638-9642,9644-9645,9647-9689,9691-9699,9703-9706,9709-9713,9716-9723,9725-9726,9730-9738,9740-9741,9750-9751,9757-9758,9761-9762,9767-9768,9770-9780,9782-9784,9789-9790,9793-9798,9801-9802,9806-9807,9809-9813,9821-9837,9842-9843,9847-9859,9861,9863-9875,9877-9881,9883-9887,9899-9903,9906-9909,9912,9914,9916-9917,9919-9920,9922-9927,9929,9931-9937,9939,9942-9943,9945-9950,9953-9954,9956-9962,9966-9977,9979-9984,9986-9988,9990-10001,10003-10004,10007,10009-10010,10013-10017,10019-10020,10022-10025,10031,10036-10041,10049-10052,10054-10061,10066-10069,10071-10076,10078-10079,10085-10087,10104,10106,10125-10127,10136,10138-10140,10143,10145-10147,10149-10160,10163-10167,10170,10173,10175-10176,10180,10185,10189,10192-10196,10198-10221,10223-10228,10230-10234,10236-10247,10250-10257,10259-10270,10273-10274,10276-10280,10282-10314,10316,10319-10322,10325,10328-10329,10333-10344,10348-10351,10354-10356,10358-10363,10365-10368,10371-10380,10386-10396 Modified: django/branches/releases/1.0.X/django/core/files/move.py =================================================================== --- django/branches/releases/1.0.X/django/core/files/move.py 2009-04-05 04:41:39 UTC (rev 10396) +++ django/branches/releases/1.0.X/django/core/files/move.py 2009-04-05 04:48:11 UTC (rev 10397) @@ -1,8 +1,8 @@ """ Move a file in the safest way possible:: - >>> from django.core.files.move import file_move_save - >>> file_move_save("/tmp/old_file", "/tmp/new_file") + >>> from django.core.files.move import file_move_safe + >>> file_move_safe("/tmp/old_file", "/tmp/new_file") """ import os @@ -39,10 +39,8 @@ """ Moves a file from one location to another in the safest way possible. - First, try using ``shutils.move``, which is OS-dependent but doesn't break - if moving across filesystems. Then, try ``os.rename``, which will break - across filesystems. Finally, streams manually from one file to another in - pure Python. + First, tries ``os.rename``, which is simple but will break across filesystems. + If that fails, streams manually from one file to another in pure Python. If the destination file exists and ``allow_overwrite`` is ``False``, this function will throw an ``IOError``. @@ -82,8 +80,9 @@ try: os.remove(old_file_name) except OSError, e: - # Certain operating systems (Cygwin and Windows) - # fail when deleting opened files, ignore it - if getattr(e, 'winerror', 0) != 32: - # FIXME: should we also ignore errno 13? + # Certain operating systems (Cygwin and Windows) + # fail when deleting opened files, ignore it. (For the + # systems where this happens, temporary files will be auto-deleted + # on close anyway.) + if getattr(e, 'winerror', 0) != 32 and getattr(e, 'errno', 0) != 13: raise --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---