Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python builtin keywords, functions, and exceptions to Python version 3 #2109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 29 additions & 32 deletions lib/rouge/lexers/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,28 @@ class Python < RegexLexer
mimetypes 'text/x-python', 'application/x-python'

def self.detect?(text)
return true if text.shebang?(/pythonw?(?:[23](?:\.\d+)?)?/)
return true if text.shebang?(/pythonw?(?:[3](?:\.\d+)?)?/)
end

def self.keywords
@keywords ||= %w(
assert break continue del elif else except exec
finally for global if lambda pass print raise
return try while yield as with from import yield
assert break continue del elif else except
finally for global if lambda pass raise
return try while yield as with from import
async await nonlocal
)
end

def self.builtins
@builtins ||= %w(
__import__ abs all any apply ascii basestring bin bool buffer
bytearray bytes callable chr classmethod cmp coerce compile
complex delattr dict dir divmod enumerate eval execfile exit
file filter float format frozenset getattr globals hasattr hash hex id
input int intern isinstance issubclass iter len list locals
long map max memoryview min next object oct open ord pow property range
raw_input reduce reload repr reversed round set setattr slice
sorted staticmethod str sum super tuple type unichr unicode
vars xrange zip
__import__ abs aiter all anext any ascii bin bool
breakpoint bytearray bytes callable chr classmethod compile
complex delattr dict dir divmod enumerate eval exec
filter float format frozenset getattr globals hasattr hash help hex id
input int isinstance issubclass iter len list locals
map max memoryview min next object oct open ord pow print property
range repr reversed round set setattr slice
sorted staticmethod str sum super tuple type vars zip
)
end

Expand All @@ -45,25 +44,23 @@ def self.builtins_pseudo

def self.exceptions
@exceptions ||= %w(
ArithmeticError AssertionError AttributeError
BaseException BlockingIOError BrokenPipeError BufferError
BytesWarning ChildProcessError ConnectionAbortedError
ConnectionError ConnectionRefusedError ConnectionResetError
DeprecationWarning EOFError EnvironmentError
Exception FileExistsError FileNotFoundError
FloatingPointError FutureWarning GeneratorExit IOError
ImportError ImportWarning IndentationError IndexError
InterruptedError IsADirectoryError KeyError KeyboardInterrupt
LookupError MemoryError ModuleNotFoundError NameError
NotADirectoryError NotImplemented NotImplementedError OSError
OverflowError OverflowWarning PendingDeprecationWarning
ProcessLookupError RecursionError ReferenceError ResourceWarning
RuntimeError RuntimeWarning StandardError StopAsyncIteration
StopIteration SyntaxError SyntaxWarning SystemError SystemExit
TabError TimeoutError TypeError UnboundLocalError UnicodeDecodeError
UnicodeEncodeError UnicodeError UnicodeTranslateError
UnicodeWarning UserWarning ValueError VMSError Warning
WindowsError ZeroDivisionError
ArithmeticError AssertionError AttributeError BaseException
BaseExceptionGroup BlockingIOError BrokenPipeError BufferError
BytesWarning ChildProcessError ConnectionAbortedError ConnectionError
ConnectionRefusedError ConnectionResetError DeprecationWarning
EOFError EncodingWarning Exception ExceptionGroup FileExistsError
FileNotFoundError FloatingPointError FutureWarning GeneratorExit
ImportError ImportWarning IndentationError IndexError InterruptedError
IsADirectoryError KeyError KeyboardInterrupt LookupError MemoryError
ModuleNotFoundError NameError NotADirectoryError NotImplementedError
OSError OverflowError PendingDeprecationWarning PermissionError
ProcessLookupError PythonFinalizationError RecursionError
ReferenceError ResourceWarning RuntimeError RuntimeWarning
StopAsyncIteration StopIteration SyntaxError SyntaxWarning SystemError
SystemExit TabError TimeoutError TypeError UnboundLocalError
UnicodeDecodeError UnicodeEncodeError UnicodeError
UnicodeTranslateError UnicodeWarning UserWarning ValueError Warning
ZeroDivisionError
)
end

Expand Down