From 55a7d3ef1eee834e4e14fbd695f94b4fb1c73d21 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Fri, 22 Jul 2016 21:51:18 +0200 Subject: Fix parsing of streams (fixes #273). --- sqlparse/lexer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sqlparse') diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 6324962..3cf2be4 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -12,6 +12,8 @@ # 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 StringIO, string_types, u @@ -39,7 +41,7 @@ class Lexer(object): """ if isinstance(text, string_types): text = u(text, encoding) - elif isinstance(text, StringIO): + elif isinstance(text, (StringIO, TextIOBase)): text = u(text.read(), encoding) iterable = enumerate(text) -- cgit v1.2.1