[issue29034] Fix memory leak in path_converter

2016-12-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There are many ways to write a solution of the original issue. You can just add a number of "Py_DECREF(bytes)" (path_converter.patch), or add new variable to_cleanup2 (path_converter-v2.patch), or reuse to_cleanup (path_converter-to_cleanup.patch), or clean

[issue29034] Fix memory leak in path_converter

2016-12-21 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file45986/path_converter-bytes.patch ___ Python tracker ___ ___ Python-bugs-l

[issue29034] Fix memory leak in path_converter

2016-12-21 Thread STINNER Victor
STINNER Victor added the comment: > The logic is complex ... Yeah, that's why I first proposed to add a dummy to_cleanup2 object. Another option is to use your first patch. I don't care much about the exact implementation :-) Maybe Serhiy has a better understanding of the code and can help to

[issue29034] Fix memory leak in path_converter

2016-12-21 Thread Xiang Zhang
Xiang Zhang added the comment: Hmm, while considering Victor's comment, I find some new: path->object refers to the original object o, it owns a borrowed reference. But when received a PathLike object, o is assigned the return value of __fspath__ and decrefed at end. So path->object could refe

[issue29034] Fix memory leak in path_converter

2016-12-21 Thread STINNER Victor
STINNER Victor added the comment: > You could just reuse to_cleanup instead of to_cleanup2. Ah, it would be better to avoid a new variable, but this code is too complex for my head. I don't understand what is to_cleanup in this code path :-) -- ___

[issue29034] Fix memory leak in path_converter

2016-12-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: You could just reuse to_cleanup instead of to_cleanup2. -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue29034] Fix memory leak in path_converter

2016-12-21 Thread Xiang Zhang
Xiang Zhang added the comment: v2 applies the comments. And another separate change is to change PyUnicode_AsWideCharString to PyUnicode_AsUnicodeAndSize. -- title: refleak in path_converter on error case -> Fix memory leak in path_converter Added file: http://bugs.python.org/file45983