summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-11-09 18:41:54 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-11-10 12:19:02 -0500
commite3a8d198917f4246365e09fa975d55c64082cd2e (patch)
tree19c47960c4ab212a59528e0f8dedf6d3a77b557f /lib/sqlalchemy/orm
parentebb54e80a5a52d0cce4cba1abc21c707a42c2c73 (diff)
downloadsqlalchemy-e3a8d198917f4246365e09fa975d55c64082cd2e.tar.gz
work around Python 3.11 IntEnum issue; update FastIntFlag
in [1], Python 3.11 seems to have changed the behavior of IntEnum. We didn't notice this because we have our own workaround class already, but typing did. Ensure we remain compatible with IntFlag. This change also modifies FastIntFlag to no longer use global symbols; this is unnecessary as we assign FastIntFlag members explicitly. Use of ``symbol()`` should probably be phased out. [1] https://github.com/python/cpython/issues/99304 Fixes: #8783 Change-Id: I8ae2e871ff1467ae5ca1f63e66b5dae45d4a6c93
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/base.py2
-rw-r--r--lib/sqlalchemy/orm/collections.py15
2 files changed, 6 insertions, 11 deletions
diff --git a/lib/sqlalchemy/orm/base.py b/lib/sqlalchemy/orm/base.py
index e4a69a352..b46c78799 100644
--- a/lib/sqlalchemy/orm/base.py
+++ b/lib/sqlalchemy/orm/base.py
@@ -188,7 +188,7 @@ class PassiveFlag(FastIntFlag):
PASSIVE_NO_FETCH,
PASSIVE_NO_FETCH_RELATED,
PASSIVE_ONLY_PERSISTENT,
-) = tuple(PassiveFlag)
+) = PassiveFlag.__members__.values()
DEFAULT_MANAGER_ATTR = "_sa_class_manager"
DEFAULT_STATE_ATTR = "_sa_instance_state"
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py
index e3051e268..0c1ccbf10 100644
--- a/lib/sqlalchemy/orm/collections.py
+++ b/lib/sqlalchemy/orm/collections.py
@@ -128,6 +128,7 @@ import weakref
from .base import NO_KEY
from .. import exc as sa_exc
from .. import util
+from ..sql.base import NO_ARG
from ..util.compat import inspect_getfullargspec
from ..util.typing import Protocol
@@ -1222,8 +1223,6 @@ def _dict_decorators() -> Dict[str, Callable[[_FN], _FN]]:
fn._sa_instrumented = True
fn.__doc__ = getattr(dict, fn.__name__).__doc__
- Unspecified = util.symbol("Unspecified")
-
def __setitem__(fn):
def __setitem__(self, key, value, _sa_initiator=None):
if key in self:
@@ -1253,10 +1252,10 @@ def _dict_decorators() -> Dict[str, Callable[[_FN], _FN]]:
return clear
def pop(fn):
- def pop(self, key, default=Unspecified):
+ def pop(self, key, default=NO_ARG):
__before_pop(self)
_to_del = key in self
- if default is Unspecified:
+ if default is NO_ARG:
item = fn(self, key)
else:
item = fn(self, key, default)
@@ -1293,8 +1292,8 @@ def _dict_decorators() -> Dict[str, Callable[[_FN], _FN]]:
return setdefault
def update(fn):
- def update(self, __other=Unspecified, **kw):
- if __other is not Unspecified:
+ def update(self, __other=NO_ARG, **kw):
+ if __other is not NO_ARG:
if hasattr(__other, "keys"):
for key in list(__other):
if key not in self or self[key] is not __other[key]:
@@ -1318,7 +1317,6 @@ def _dict_decorators() -> Dict[str, Callable[[_FN], _FN]]:
l = locals().copy()
l.pop("_tidy")
- l.pop("Unspecified")
return l
@@ -1346,8 +1344,6 @@ def _set_decorators() -> Dict[str, Callable[[_FN], _FN]]:
fn._sa_instrumented = True
fn.__doc__ = getattr(set, fn.__name__).__doc__
- Unspecified = util.symbol("Unspecified")
-
def add(fn):
def add(self, value, _sa_initiator=None):
if value not in self:
@@ -1500,7 +1496,6 @@ def _set_decorators() -> Dict[str, Callable[[_FN], _FN]]:
l = locals().copy()
l.pop("_tidy")
- l.pop("Unspecified")
return l