]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix typo in resultproxy.c and test compatibility with python 3.5
authorFederico Caselli <cfederico87@gmail.com>
Sat, 28 Mar 2020 10:04:44 +0000 (11:04 +0100)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Mar 2020 17:23:12 +0000 (13:23 -0400)
- Fix typo in resultproxy.c that would error on windows.
- add -Wundef to C flags when linux is detected so that undefined
symbols emit a warning
- a few adjustments for tests to succeed on python 3.5
- note minimum version still documented here as 3.4 but this should
move to at least 3.5 if not 3.6 for SQLAlchemy 1.4

Change-Id: Ia93ee1cb5c52e51e72eb0a24c100421c5157d04b

lib/sqlalchemy/cextension/resultproxy.c
lib/sqlalchemy/testing/util.py
setup.py
test/base/test_utils.py
test/orm/test_unitofwork.py

index f622e6a28848d8de748633ba529d9e614b5db538..b105038bcec93839ffafc7ee3d6894d9914a2ad4 100644 (file)
@@ -21,7 +21,7 @@ typedef Py_ssize_t (*lenfunc)(PyObject *);
 typedef intargfunc ssizeargfunc;
 #endif
 
-#if PY_MAJOR_VERSON < 3
+#if PY_MAJOR_VERSION < 3
 
 // new typedef in Python 3
 typedef long Py_hash_t;
@@ -359,7 +359,7 @@ BaseRow_subscript_impl(BaseRow *self, PyObject *key, int asmapping)
             /* -1 can be either the actual value, or an error flag. */
             return NULL;
         if (index < 0)
-            index += BaseRow_length(self);
+            index += (long)BaseRow_length(self);
         return BaseRow_getitem(self, index);
     } else if (PySlice_Check(key)) {
         values = PyObject_GetItem(self->row, key);
index c52dc4a19b524fe11c5cd408211e9f14e005a1fe..586974f11b2a5ebaf83cca79aaf9a0a6dd0b9faa 100644 (file)
@@ -17,6 +17,7 @@ from ..util import defaultdict
 from ..util import has_refcount_gc
 from ..util import inspect_getfullargspec
 from ..util import py2k
+from ..util import py36
 
 if not has_refcount_gc:
 
@@ -53,7 +54,7 @@ def picklers():
             yield pickle_.loads, lambda d: pickle_.dumps(d, protocol)
 
 
-if py2k:
+if py2k or not py36:
 
     def random_choices(population, k=1):
         pop = list(population)
index cb117d78752ff50d9ef4c291fa85087bf7d1d8b5..e77c617b421c613843988fad8c98a616eaba3512 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -20,27 +20,35 @@ if sys.version_info < (2, 7):
 
 cpython = platform.python_implementation() == "CPython"
 
+ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
+if sys.platform == "win32":
+    # Work around issue https://github.com/pypa/setuptools/issues/1902
+    ext_errors += (IOError, TypeError)
+    extra_compile_args = []
+elif sys.platform == "linux":
+    # warn for undefined symbols in .c files
+    extra_compile_args = ["-Wundef"]
+else:
+    extra_compile_args = []
+
 ext_modules = [
     Extension(
         "sqlalchemy.cprocessors",
         sources=["lib/sqlalchemy/cextension/processors.c"],
+        extra_compile_args=extra_compile_args,
     ),
     Extension(
         "sqlalchemy.cresultproxy",
         sources=["lib/sqlalchemy/cextension/resultproxy.c"],
+        extra_compile_args=extra_compile_args,
     ),
     Extension(
-        "sqlalchemy.cutils", sources=["lib/sqlalchemy/cextension/utils.c"]
+        "sqlalchemy.cutils",
+        sources=["lib/sqlalchemy/cextension/utils.c"],
+        extra_compile_args=extra_compile_args,
     ),
 ]
 
-ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
-if sys.platform == "win32":
-    # 2.6's distutils.msvc9compiler can raise an IOError when failing to
-    # find the compiler
-    # for TypeError, see https://github.com/pypa/setuptools/issues/1902
-    ext_errors += (IOError, TypeError)
-
 
 class BuildFailed(Exception):
     def __init__(self):
index 662baa38a46399f292db508e807a4121ccfc6a77..246199861fb85165750a9f894da04a11d1a346b2 100644 (file)
@@ -3185,6 +3185,8 @@ class TimezoneTest(fixtures.TestBase):
         ),
     )
     def test_tzname(self, td, expected):
+        if expected == "UTC" and util.py3k and not util.py36:
+            expected += "+00:00"
         eq_(timezone(td).tzname(None), expected)
 
     def test_utcoffset(self):
index 2813c1e7e08620d2ff536201787ecec1424c1272..3a1594a61359b9b79a999f05b625a934d3a770d4 100644 (file)
@@ -3472,12 +3472,22 @@ class EnsurePKSortableTest(fixtures.MappedTest):
         a.data = "bar"
         b.data = "foo"
         if sa.util.py3k:
+            if sa.util.py36:
+                message = (
+                    r"Could not sort objects by primary key; primary key "
+                    r"values must be sortable in Python \(was: '<' not "
+                    r"supported between instances of 'MyNotSortableEnum'"
+                    r" and 'MyNotSortableEnum'\)"
+                )
+            else:
+                message = (
+                    r"Could not sort objects by primary key; primary key "
+                    r"values must be sortable in Python \(was: unorderable "
+                    r"types: MyNotSortableEnum\(\) < MyNotSortableEnum\(\)\)"
+                )
+
             assert_raises_message(
-                sa.exc.InvalidRequestError,
-                r"Could not sort objects by primary key; primary key values "
-                r"must be sortable in Python \(was: '<' not supported between "
-                r"instances of 'MyNotSortableEnum' and 'MyNotSortableEnum'\)",
-                s.flush,
+                sa.exc.InvalidRequestError, message, s.flush,
             )
         else:
             s.flush()