Fixed issue where support for logging "stacklevel" implemented in
:ticket:`7612` required adjustment to work with recently released Python
3.11.0b1, also repairs the unit tests which tested this feature.
Install greenlet from a py311 compat patch.
re: the stacklevel thing, this is going to be very inconvenient
if we have to keep hardcoding numbers everywhere for every
new python version
Change-Id: I0c8f7293e98c0ca5cc544538284bfd1d3020cb1f
References: https://github.com/python-greenlet/greenlet/issues/288
Fixes: #8019
(cherry picked from commit
43ff5b82dc0d91cacd625ac8943622ab340958c5)
--- /dev/null
+.. change::
+ :tags: bug, engine, tests
+ :tickets: 8019
+
+ Fixed issue where support for logging "stacklevel" implemented in
+ :ticket:`7612` required adjustment to work with recently released Python
+ 3.11.0b1, also repairs the unit tests which tested this feature.
if fmt:
message = fmt(message)
- if util.py38:
- kw["stacklevel"] = 2
+ if log.STACKLEVEL:
+ kw["stacklevel"] = 1 + log.STACKLEVEL_OFFSET
self.engine.logger.info(message, *arg, **kw)
if fmt:
message = fmt(message)
- if util.py38:
- kw["stacklevel"] = 2
+ if log.STACKLEVEL:
+ kw["stacklevel"] = 1 + log.STACKLEVEL_OFFSET
self.engine.logger.debug(message, *arg, **kw)
import logging
import sys
+from .util import py311
from .util import py38
+if py38:
+ STACKLEVEL = True
+ # needed as of py3.11.0b1
+ # #8019
+ STACKLEVEL_OFFSET = 2 if py311 else 1
+else:
+ STACKLEVEL = False
+ STACKLEVEL_OFFSET = 0
+
# set initial level to WARN. This so that
# log statements don't occur in the absence of explicit
# logging being enabled for 'sqlalchemy'.
selected_level = self.logger.getEffectiveLevel()
if level >= selected_level:
- if py38:
- kwargs["stacklevel"] = kwargs.get("stacklevel", 1) + 1
+ if STACKLEVEL:
+ kwargs["stacklevel"] = (
+ kwargs.get("stacklevel", 1) + STACKLEVEL_OFFSET
+ )
self.logger._log(level, msg, args, **kwargs)
return exclusions.closed()
+ @property
+ def asyncio(self):
+ return self.greenlet
+
@property
def greenlet(self):
def go(config):
from .compat import pickle
from .compat import print_
from .compat import py2k
+from .compat import py311
from .compat import py37
from .compat import py38
from .compat import py39
import platform
import sys
+py311 = sys.version_info >= (3, 11)
py39 = sys.version_info >= (3, 9)
py38 = sys.version_info >= (3, 8)
py37 = sys.version_info >= (3, 7)
class TextSyncDBAPI(fixtures.TestBase):
+ __requires__ = ("asyncio",)
+
def test_sync_dbapi_raises(self):
with expect_raises_message(
exc.InvalidRequestError,
def async_dialect(self):
"""dialect makes use of await_() to invoke operations on the DBAPI."""
- return only_on(
+ return self.asyncio + only_on(
LambdaPredicate(
lambda config: config.db.dialect.is_async,
"Async dialect required",
pytest-xdist
mock; python_version < '3.3'
+ # cython and greenlet both not working on 3.11
+ # note cython not working for 3.11 at all right now
+ git+https://github.com/sqlalchemyorg/greenlet/@fix_py311_cpp#egg=greenlet; python_version >= '3.11'
+
sqlite: .[aiosqlite]
sqlite_file: .[aiosqlite]
sqlite_file: .[sqlcipher]; python_version >= '3' and python_version < '3.10'