[issue10896] trace module compares directories as strings (--ignore-dir)

Vladimir Rutsky report at bugs.python.org
Wed Jan 12 15:44:49 CET 2011


New submission from Vladimir Rutsky <rutsky.vladimir at gmail.com>:

This is code from recent trace.py (http://svn.python.org/view/python/branches/release27-maint/Lib/trace.py?view=markup):

trace.py:169:
        # Ignore a file when it contains one of the ignorable paths
        for d in self._dirs:
            # The '+ os.sep' is to ensure that d is a parent directory,
            # as compared to cases like:
            #  d = "/usr/local"
            #  filename = "/usr/local.py"
            # or
            #  d = "/usr/local.py"
            #  filename = "/usr/local.py"
            if filename.startswith(d + os.sep):
                self._ignore[modulename] = 1
                return 1

Directories comparison like "filename.startswith(d + os.sep)" works incorrect on case-insensitive filesystems (such as NTFS on Windows).

This leads to confusing results on Windows:
  python trace.py --ignore-dir='$prefix' -t test.py
or
  python trace.py --ignore-dir C:\Python26\Lib -t test.py
shows all calls from standard library, but this one doesn't:
  python trace.py --ignore-dir=c:\python26\lib -t test.py

See attached test files and log for details.

----------
components: Library (Lib)
files: test.py
messages: 126101
nosy: vrutsky
priority: normal
severity: normal
status: open
title: trace module compares directories as strings (--ignore-dir)
versions: Python 2.7
Added file: http://bugs.python.org/file20368/test.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10896>
_______________________________________


More information about the Python-bugs-list mailing list