diff options
Diffstat (limited to 'pygments/lexers/agile.py')
-rw-r--r-- | pygments/lexers/agile.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index 61b05f93..ae2456ff 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -37,8 +37,8 @@ class PythonLexer(RegexLexer): """ name = 'Python' - aliases = ['python', 'py'] - filenames = ['*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac'] + aliases = ['python', 'py', 'sage'] + filenames = ['*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage'] mimetypes = ['text/x-python', 'application/x-python'] tokens = { @@ -135,7 +135,14 @@ class PythonLexer(RegexLexer): 'fromimport': [ (r'(?:[ \t]|\\\n)+', Text), (r'import\b', Keyword.Namespace, '#pop'), + # if None occurs here, it's "raise x from None", since None can + # never be a module name + (r'None\b', Name.Builtin.Pseudo, '#pop'), + # sadly, in "raise x from y" y will be highlighted as namespace too (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace), + # anything else here also means "raise x from y" and is therefore + # not an error + (r'', Text, '#pop'), ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|' |