Skip to content

Commit a497aec

Browse files
committed
Convert command-line arguments to Unicode before continuing.
This fixes a problem with current SQLAlchemy, which will warn (or even throw an exception if configured in strict mode) when you try to access a Unicode column with a non-Unicode string. Yes, even under PY2.
1 parent 56123e7 commit a497aec

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

flask_script/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import argparse
1212

1313
from flask import Flask
14+
from flask._compat import text_type
1415

1516
from ._compat import iteritems
1617
from .commands import Group, Option, Command, Server, Shell
@@ -405,11 +406,13 @@ def run(self, commands=None, default_command=None):
405406
if commands:
406407
self._commands.update(commands)
407408

408-
if default_command is not None and len(sys.argv) == 1:
409-
sys.argv.append(default_command)
409+
# Make sure all of this is Unicode
410+
argv = list(text_type(arg) for arg in sys.argv)
411+
if default_command is not None and len(argv) == 1:
412+
argv.append(default_command)
410413

411414
try:
412-
result = self.handle(sys.argv[0], sys.argv[1:])
415+
result = self.handle(argv[0], argv[1:])
413416
except SystemExit as e:
414417
result = e.code
415418

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import sys
1515
from setuptools import setup
1616

17+
version='2.0.6'
18+
1719
# Hack to prevent stupid TypeError: 'NoneType' object is not callable error on
1820
# exit of python setup.py test # in multiprocessing/util.py _exit_function when
1921
# running python setup.py test (see
@@ -27,9 +29,9 @@
2729

2830
setup(
2931
name='Flask-Script',
30-
version='2.0.5',
32+
version=version,
3133
url='http://github.com/smurfix/flask-script',
32-
download_url = 'https://github.com/smurfix/flask-script/tarball/v2.0.3',
34+
download_url = 'https://github.com/smurfix/flask-script/tarball/v'+version,
3335
license='BSD',
3436
author='Dan Jacob',
3537
author_email='danjac354@gmail.com',

tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def test_run_catch_all(self, capsys):
567567
code = run('manage.py catch pos1 --foo pos2 --bar', manager.run)
568568
out, err = capsys.readouterr()
569569
assert code == 0
570-
assert "['pos1', 'pos2', '--bar']" in out
570+
assert "[u'pos1', u'pos2', u'--bar']" in out
571571

572572
def test_run_bad_options(self, capsys):
573573
manager = Manager(self.app)

0 commit comments

Comments
 (0)