[python-sqlalchemy0.5] Patch to fix https://rhn.redhat.com/errata/RHSA-2012-0369.html
Toshio くらとみ
toshio at fedoraproject.org
Wed Mar 7 16:19:00 UTC 2012
commit 48e0cf5c7432bdc453cb72d1c0d2c07b006fe0e6
Author: Toshio Kuratomi <toshio at fedoraproject.org>
Date: Wed Mar 7 08:18:53 2012 -0800
Patch to fix https://rhn.redhat.com/errata/RHSA-2012-0369.html
SQLAlchemy-0.5.5-coerce-limit-offset-to-int.patch | 82 +++++++++++++++++++++
python-sqlalchemy0.5.spec | 6 ++
2 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/SQLAlchemy-0.5.5-coerce-limit-offset-to-int.patch b/SQLAlchemy-0.5.5-coerce-limit-offset-to-int.patch
new file mode 100644
index 0000000..d0ed5a9
--- /dev/null
+++ b/SQLAlchemy-0.5.5-coerce-limit-offset-to-int.patch
@@ -0,0 +1,82 @@
+Index: SQLAlchemy-0.5.8/lib/sqlalchemy/sql/expression.py
+===================================================================
+--- SQLAlchemy-0.5.8.orig/lib/sqlalchemy/sql/expression.py
++++ SQLAlchemy-0.5.8/lib/sqlalchemy/sql/expression.py
+@@ -2994,8 +2994,8 @@ class _SelectBaseMixin(object):
+ self.use_labels = use_labels
+ self.for_update = for_update
+ self._autocommit = autocommit
+- self._limit = limit
+- self._offset = offset
++ self._limit = util.asint(limit)
++ self._offset = util.asint(offset)
+ self._bind = bind
+
+ self._order_by_clause = ClauseList(*util.to_list(order_by) or [])
+@@ -3050,13 +3050,13 @@ class _SelectBaseMixin(object):
+ def limit(self, limit):
+ """return a new selectable with the given LIMIT criterion applied."""
+
+- self._limit = limit
++ self._limit = util.asint(limit)
+
+ @_generative
+ def offset(self, offset):
+ """return a new selectable with the given OFFSET criterion applied."""
+
+- self._offset = offset
++ self._offset = util.asint(offset)
+
+ @_generative
+ def order_by(self, *clauses):
+Index: SQLAlchemy-0.5.8/lib/sqlalchemy/util.py
+===================================================================
+--- SQLAlchemy-0.5.8.orig/lib/sqlalchemy/util.py
++++ SQLAlchemy-0.5.8/lib/sqlalchemy/util.py
+@@ -1533,3 +1533,10 @@ def _decorate_with_warning(func, wtype,
+ decorated = warned(func)
+ decorated.__doc__ = doc
+ return decorated
++
++def asint(value):
++ """Coerce to integer."""
++
++ if value is None:
++ return value
++ return int(value)
+Index: SQLAlchemy-0.5.8/test/sql/test_select.py
+===================================================================
+--- SQLAlchemy-0.5.8.orig/test/sql/test_select.py
++++ SQLAlchemy-0.5.8/test/sql/test_select.py
+@@ -1,5 +1,5 @@
+ from sqlalchemy.test.testing import eq_, assert_raises, assert_raises_message
+-import datetime, re, operator
++import datetime, re, operator, decimal
+ from sqlalchemy import *
+ from sqlalchemy import exc, sql, util
+ from sqlalchemy.sql import table, column, label, compiler
+@@ -80,6 +80,24 @@ myothertable.othername FROM mytable, myo
+ 'FROM mytable, myothertable', 'FROM myothertable, mytable'))
+
+
++ def test_int_limit_offset_coercion(self):
++ for given, exp in [
++ ("5", 5),
++ (5, 5),
++ (5.2, 5),
++ (decimal.Decimal("5"), 5),
++ (None, None),
++ ]:
++ eq_(select().limit(given)._limit, exp)
++ eq_(select().offset(given)._offset, exp)
++ eq_(select(limit=given)._limit, exp)
++ eq_(select(offset=given)._offset, exp)
++
++ assert_raises(ValueError, select().limit, "foo")
++ assert_raises(ValueError, select().offset, "foo")
++ assert_raises(ValueError, select, offset="foo")
++ assert_raises(ValueError, select, limit="foo")
++
+ def test_from_subquery(self):
+ """tests placing select statements in the column clause of another select, for the
+ purposes of selecting from the exported columns of that select."""
diff --git a/python-sqlalchemy0.5.spec b/python-sqlalchemy0.5.spec
index fb41dda..0bbba9a 100644
--- a/python-sqlalchemy0.5.spec
+++ b/python-sqlalchemy0.5.spec
@@ -15,6 +15,8 @@ URL: http://www.sqlalchemy.org/
Source0: http://pypi.python.org/packages/source/S/%{srcname}/%{srcname}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Patch0: python-sqlalchemy0.5-py27.patch
+# Fix https://rhn.redhat.com/errata/RHSA-2012-0369.html
+Patch1: SQLAlchemy-0.5.5-coerce-limit-offset-to-int.patch
BuildArch: noarch
BuildRequires: python-devel
@@ -37,6 +39,7 @@ domain.
%prep
%setup -q -n %{srcname}-%{version}
%patch0 -p1
+%patch1 -p1
%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py bdist_egg
@@ -69,6 +72,9 @@ nosetests
%{python_sitelib}/*
%changelog
+* Wed Mar 7 2012 Toshio Kuratomi <toshio at fedoraproject.org> - 0.5.8-7
+- Patch to fix https://rhn.redhat.com/errata/RHSA-2012-0369.html
+
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.5.8-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list