From 5c86d3914cb2ddb3333f47e35f5fe7a34bca882b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 15 Dec 2011 10:31:55 -0500 Subject: [PATCH] - [bug] Fixed inappropriate usage of util.py3k flag and renamed it to util.py3k_warning, since this flag is intended to detect the -3 flag series of import restrictions only. [ticket:2348] --- CHANGES | 7 +++++++ lib/sqlalchemy/orm/collections.py | 2 +- lib/sqlalchemy/util/__init__.py | 2 +- lib/sqlalchemy/util/compat.py | 17 ++++++++-------- lib/sqlalchemy/util/langhelpers.py | 31 +++++++++++++++--------------- test/lib/testing.py | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index 2b4959e907..f5540e1e0f 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,13 @@ CHANGES - [bug] Fixed bug whereby hybrid_property didn't work as a kw arg in any(), has(). +- Py3K + - [bug] Fixed inappropriate usage of util.py3k + flag and renamed it to util.py3k_warning, since + this flag is intended to detect the -3 flag + series of import restrictions only. + [ticket:2348] + 0.7.4 ===== - orm diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index d605d849bc..7c82f37350 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -1166,7 +1166,7 @@ def _dict_decorators(): l.pop('Unspecified') return l -if util.py3k: +if util.py3k_warning: _set_binop_bases = (set, frozenset) else: import sets diff --git a/lib/sqlalchemy/util/__init__.py b/lib/sqlalchemy/util/__init__.py index c78cddf778..d1a72eaf24 100644 --- a/lib/sqlalchemy/util/__init__.py +++ b/lib/sqlalchemy/util/__init__.py @@ -5,7 +5,7 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php from compat import callable, cmp, reduce, defaultdict, py25_dict, \ - threading, py3k, jython, pypy, win32, set_types, buffer, pickle, \ + threading, py3k_warning, jython, pypy, win32, set_types, buffer, pickle, \ update_wrapper, partial, md5_hex, decode_slice, dottedgetter,\ parse_qsl diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index 380e3a9a59..18549c8b9f 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -18,12 +18,12 @@ except ImportError: import dummy_threading as threading py32 = sys.version_info >= (3, 2) -py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) +py3k_warning = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0) jython = sys.platform.startswith('java') pypy = hasattr(sys, 'pypy_version_info') win32 = sys.platform.startswith('win') -if py3k: +if py3k_warning: set_types = set elif sys.version_info < (2, 6): import sets @@ -43,7 +43,7 @@ else: set_types = set, sets.Set -if py3k: +if py3k_warning: import pickle else: try: @@ -89,12 +89,13 @@ if sys.version_info < (2, 6): else: from urlparse import parse_qsl -if py3k: - from inspect import getfullargspec as inspect_getfullargspec -else: - from inspect import getargspec as inspect_getfullargspec +# Py3K +#from inspect import getfullargspec as inspect_getfullargspec +# Py2K +from inspect import getargspec as inspect_getfullargspec +# end Py2K -if py3k: +if py3k_warning: # they're bringing it back in 3.2. brilliant ! def callable(fn): return hasattr(fn, '__call__') diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 722003796d..f10ab3fb59 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -15,7 +15,7 @@ import re import sys import types import warnings -from compat import update_wrapper, set_types, threading, callable, inspect_getfullargspec, py3k +from compat import update_wrapper, set_types, threading, callable, inspect_getfullargspec, py3k_warning from sqlalchemy import exc def _unique_symbols(used, *bases): @@ -162,20 +162,21 @@ def format_argspec_plus(fn, grouped=True): else: self_arg = None - if py3k: - apply_pos = inspect.formatargspec(spec[0], spec[1], spec[2], None, spec[4]) - num_defaults = 0 - if spec[3]: - num_defaults += len(spec[3]) - if spec[4]: - num_defaults += len(spec[4]) - name_args = spec[0] + spec[4] - else: - apply_pos = inspect.formatargspec(spec[0], spec[1], spec[2]) - num_defaults = 0 - if spec[3]: - num_defaults += len(spec[3]) - name_args = spec[0] + # Py3K + #apply_pos = inspect.formatargspec(spec[0], spec[1], spec[2], None, spec[4]) + #num_defaults = 0 + #if spec[3]: + # num_defaults += len(spec[3]) + #if spec[4]: + # num_defaults += len(spec[4]) + #name_args = spec[0] + spec[4] + # Py2K + apply_pos = inspect.formatargspec(spec[0], spec[1], spec[2]) + num_defaults = 0 + if spec[3]: + num_defaults += len(spec[3]) + name_args = spec[0] + # end Py2K if num_defaults: defaulted_vals = name_args[0-num_defaults:] diff --git a/test/lib/testing.py b/test/lib/testing.py index 90e8b7746d..53a277b9df 100644 --- a/test/lib/testing.py +++ b/test/lib/testing.py @@ -10,7 +10,7 @@ from cStringIO import StringIO from test.bootstrap import config from test.lib import assertsql, util as testutil -from sqlalchemy.util import py3k, decorator +from sqlalchemy.util import decorator from engines import drop_all_tables from sqlalchemy import exc as sa_exc, util, types as sqltypes, schema, \ -- 2.47.2