From 87793536399b7c7aaade812e0bcec0997a26304b Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Wed, 23 Oct 2013 00:30:51 -0700 Subject: [PATCH] Don't assume stream is seekable. --- sqlalchemy_utils/functions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlalchemy_utils/functions/__init__.py b/sqlalchemy_utils/functions/__init__.py index 4370e7d..7b25426 100644 --- a/sqlalchemy_utils/functions/__init__.py +++ b/sqlalchemy_utils/functions/__init__.py @@ -271,7 +271,7 @@ def create_mock_engine(bind, stream=None): text = re.sub(r'\n+', '\n', text) text = text.strip('\n').strip() - if stream.tell() > 0: + if not stream.seekable() or stream.tell() > 0: stream.write('\n') stream.write(text)