diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2020-09-13 08:54:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-13 08:54:12 +0200 |
| commit | 6cb3821bf3b048c7b4182c3d87432c433a5f1a57 (patch) | |
| tree | 2a3849c872dd7cbcda0d92323811394049ca03a5 /sqlparse/lexer.py | |
| parent | db4a9f49286b13a4e9deb810645dd5fc1400b804 (diff) | |
| parent | 686bf6d3c5b2598952a752e708e5d0419fa64781 (diff) | |
| download | sqlparse-6cb3821bf3b048c7b4182c3d87432c433a5f1a57.tar.gz | |
Merge branch 'master' into w503
Diffstat (limited to 'sqlparse/lexer.py')
| -rw-r--r-- | sqlparse/lexer.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index fd007a4..836d53d 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Copyright (C) 2009-2018 the sqlparse authors and contributors # <see AUTHORS file> @@ -13,13 +12,14 @@ # It's separated from the rest of pygments to increase performance # and to allow some customizations. +from io import TextIOBase + from sqlparse import tokens from sqlparse.keywords import SQL_REGEX -from sqlparse.compat import text_type, file_types from sqlparse.utils import consume -class Lexer(object): +class Lexer: """Lexer Empty class. Leaving for backwards-compatibility """ @@ -38,10 +38,10 @@ class Lexer(object): ``stack`` is the initial stack (default: ``['root']``) """ - if isinstance(text, file_types): + if isinstance(text, TextIOBase): text = text.read() - if isinstance(text, text_type): + if isinstance(text, str): pass elif isinstance(text, bytes): if encoding: @@ -52,7 +52,7 @@ class Lexer(object): except UnicodeDecodeError: text = text.decode('unicode-escape') else: - raise TypeError(u"Expected text or file-like object, got {!r}". + raise TypeError("Expected text or file-like object, got {!r}". format(type(text))) iterable = enumerate(text) |
