[New-bugs-announce] [issue31561] difflib pathological behavior with mixed line endings

Mahmoud Al-Qudsi report at bugs.python.org
Sat Sep 23 13:01:19 EDT 2017

New submission from Mahmoud Al-Qudsi:

While using the icdiff command line interface to difflib, I ran into an interesting issue where difflib took 47 seconds to compare two simple text documents (a PHP source code file that had been refactored via phptidy).

On subsequent analysis, it turned out to be some sort of pathological behavior triggered by the presence of mixed line endings. Normalizing the line endings in both files to \r\n via unix2dos and then comparing (making no other changes) resulted in the diff calculation completing in under 2 seconds.

I have attached the documents in question (file1 and file2) to this bug report.

components: Library (Lib)
files: file1
messages: 302788
nosy: Mahmoud Al-Qudsi
priority: normal
severity: normal
status: open
title: difflib pathological behavior with mixed line endings
versions: Python 3.6
Added file: https://bugs.python.org/file47164/file1

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list