-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Description
Hi Anatoly:
the code in
http://code.google.com/p/python-patch/source/browse/trunk/patch.py#89 is not
cross platform and will yield different results when running on posix or
windows.
What steps will reproduce the problem?
Using a patch like this: http://drupal.org/files/issues/drupal_upload.patch
diff -Nup C:\Documents and Settings\Boki\Desktop\head\patches\drupal6/drupal.js
C:\Documents and Settings\Boki\Desktop\head\patches\parallel uploads/drupal.js
--- C:\Documents and
Settings\Boki\Desktop\head\patches\drupal6/drupal.js 2007-06-08
14:52:00.000000000 +0200
+++ C:\Documents and Settings\Boki\Desktop\head\patches\parallel
uploads/drupal.js 2007-06-16 19:27:20.953125000 +0200
We will get on posix after parsing the patch:
source: Documents and Settings\Boki\Desktop\head\patches\drupal6/drupal.js
target: Documents and Settings\Boki\Desktop\head\patches\parallel
uploads/drupal.js
And on Windows:
source: Documents and Settings/Boki/Desktop/head/patches/drupal6/drupal.js
target: Documents and Settings/Boki/Desktop/head/patches/parallel
uploads/drupal.js
What is the expected output? What do you see instead?
=>The output should be the same on all OS
Actual output on win:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import patch
>>> p=patch.fromurl('http://drupal.org/files/issues/drupal_upload.patch')
>>> p.items[0].source
'Documents and Settings/Boki/Desktop/head/patches/drupal6/drupal.js'
>>> p.items[0].target
'Documents and Settings/Boki/Desktop/head/patches/parallel uploads/drupal.js'
Actual output on posix (here with cugwin, but the same behavior has been
verified on Linux and Macosx):
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import patch
>>> p=patch.fromurl('http://drupal.org/files/issues/drupal_upload.patch')
>>> p.items[0].source
'Documents and Settings\\Boki\\Desktop\\head\\patches\\drupal6/drupal.js'
>>> p.items[0].target
'Documents and Settings\\Boki\\Desktop\\head\\patches\\parallel
uploads/drupal.js'
Tell me if you want a patch... The strategy I use in general for cross-os path
handling is to convert at the boundaries any path to posix, and use internally
the posixpath module for all path handling, converting back to os.path-specific
path on demand for thing that require actual IOs to os files.
--
Cordially
Philippe
Original issue reported on code.google.com by pombreda...@gmail.com on 20 Apr 2013 at 11:01