From 2681beb23e3a8d9d905d99f9e67bb0389264f44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 12 Mar 2007 11:01:10 +0000 Subject: Patch #1677862: Require a space or tab after import in .pth files. --- Doc/lib/libsite.tex | 17 +++++++++++------ Lib/site.py | 2 +- Misc/NEWS | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Doc/lib/libsite.tex b/Doc/lib/libsite.tex index c079790..11858d1 100644 --- a/Doc/lib/libsite.tex +++ b/Doc/lib/libsite.tex @@ -28,12 +28,17 @@ the newly added path for configuration files. A path configuration file is a file whose name has the form \file{\var{package}.pth} and exists in one of the four directories -mentioned above; its contents are additional items (one -per line) to be added to \code{sys.path}. Non-existing items are -never added to \code{sys.path}, but no check is made that the item -refers to a directory (rather than a file). No item is added to -\code{sys.path} more than once. Blank lines and lines beginning with -\code{\#} are skipped. Lines starting with \code{import} are executed. +mentioned above; its contents are additional items (one per line) to +be added to \code{sys.path}. Non-existing items are never added to +\code{sys.path}, but no check is made that the item refers to a +directory (rather than a file). No item is added to \code{sys.path} +more than once. Blank lines and lines beginning with \code{\#} are +skipped. Lines starting with \code{import} (followed by space or tab) +are executed. + +\versionchanged[A space or tab is now required after the import +keyword]{2.6} + \index{package} \indexiii{path}{configuration}{file} diff --git a/Lib/site.py b/Lib/site.py index 113f221..5033f8a 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -134,7 +134,7 @@ def addpackage(sitedir, name, known_paths): for line in f: if line.startswith("#"): continue - if line.startswith("import"): + if line.startswith("import ") or line.startswith("import\t"): exec line continue line = line.rstrip() diff --git a/Misc/NEWS b/Misc/NEWS index f3785fb..e34964e 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -158,6 +158,8 @@ Core and builtins Library ------- +- Patch #1677862: Require a space or tab after import in .pth files. + - Patch #1192590: Fix pdb's "ignore" and "condition" commands so they trap the IndexError caused by passing in an invalid breakpoint number. -- cgit v0.12