techtonik / python-patch

Library to parse and apply unified diffs
https://pypi.python.org/pypi/patch
112 stars 64 forks source link

Patch: Python 3.x support #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 9 years ago
Hiho..  I wanted to use this as a library in a Python 3.x application, so I 
went ahead and made the necessary modifications to make it run under both 2.x 
and 3.x (patch is attached)

It passes all the provided tests, and works nicely for my project with the 
patch applied, but I do note that one of the things I had to fiddle with a bit 
is the different way that file IO is handled (particularly with respect to 
newlines) in Py3.  I think the changes I made should result in similar behavior 
in both versions, but I haven't done really extensive testing...

Original issue reported on code.google.com by foogod@gmail.com on 28 Aug 2010 at 2:20

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the contribution. It is good to know that python-patch is used in 
real projects. Feel free to submit a link when your project is released for a 
list of adoptions.

As for the patch - it looks good, but porting myself to Python 3 is on TODO 
list, so I am not yet ready to estimate the impact. Test suite unfortunately 
doesn't cover all use cases - only the major ones, so I can't safely accept 
them as enough for commit.

Right now my focus is on improving parser to be more extensible and staying to 
be non-recursive at the same time. This will allow to parse Git and HG patches, 
but also may change some essential things, so until this work is finished I'd 
refrain from porting things to Python 3k. But Py3k will happen sooner or later 
for sure, so your effort won't go unnoticed.

Original comment by techtonik@gmail.com on 28 Aug 2010 at 10:43

GoogleCodeExporter commented 9 years ago
Here's an updated version of the patch: 
http://p.sipsolutions.net/ab76e67a1d847572.txt

I didn't do the test stuff though because I don't even use that :)

Original comment by Berg...@gmail.com on 4 Jun 2013 at 12:23

GoogleCodeExporter commented 9 years ago
Result of previous patch manually adapted to r196

Original comment by alt...@gmail.com on 25 Jun 2013 at 9:02

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the patch. String unicoding features of Python 3 are killing me, but 
it certainly becomes easier to understand what works and what's not with this 
patch. No promises when I integrate it yet. I am afraid the API isn't ready, so 
to avoid breaking things in one version, then in another, I need to build up 
the motivation to cover change with tests.

Original comment by techtonik@gmail.com on 25 Jun 2013 at 3:31

jvican commented 8 years ago

Is this usable at all? Thanks.

techtonik commented 8 years ago

No, unfortunately I run out of cash and have to spend my time on other activities.

techtonik commented 8 years ago

Created new issue to track from scratch.