From: Mike Bayer Date: Mon, 7 Feb 2022 19:52:03 +0000 (-0500) Subject: add conditional for fileConfig() X-Git-Tag: rel_1_7_7~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cacce364c345a849bedd3708167ee20245f6bcda;p=thirdparty%2Fsqlalchemy%2Falembic.git add conditional for fileConfig() The ``fileConfig()`` line in the ``env.py`` templates is now conditional on ``Config.config_file_name`` not being None. Change-Id: Ibe943d093fd872c4d0a836f58e0608a4e078ce1f Fixes: #986 --- diff --git a/alembic/templates/async/env.py b/alembic/templates/async/env.py index 4ac2b6ac..61030dcf 100644 --- a/alembic/templates/async/env.py +++ b/alembic/templates/async/env.py @@ -13,7 +13,8 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. -fileConfig(config.config_file_name) +if config.config_file_name is not None: + fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support diff --git a/alembic/templates/generic/env.py b/alembic/templates/generic/env.py index 70518a2e..edeff1d5 100644 --- a/alembic/templates/generic/env.py +++ b/alembic/templates/generic/env.py @@ -11,7 +11,8 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. -fileConfig(config.config_file_name) +if config.config_file_name is not None: + fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support diff --git a/alembic/templates/multidb/env.py b/alembic/templates/multidb/env.py index f1a9a9ad..687f5843 100644 --- a/alembic/templates/multidb/env.py +++ b/alembic/templates/multidb/env.py @@ -15,7 +15,8 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. -fileConfig(config.config_file_name) +if config.config_file_name is not None: + fileConfig(config.config_file_name) logger = logging.getLogger("alembic.env") # gather section names referring to different diff --git a/alembic/templates/pylons/env.py b/alembic/templates/pylons/env.py index b2d610d7..18d47c85 100644 --- a/alembic/templates/pylons/env.py +++ b/alembic/templates/pylons/env.py @@ -21,7 +21,8 @@ except: # can use config['__file__'] here, i.e. the Pylons # ini file, instead of alembic.ini config_file = config.get_main_option("pylons_config_file") - fileConfig(config_file) + if config_file is not None: + fileConfig(config_file) wsgi_app = loadapp("config:%s" % config_file, relative_to=".") diff --git a/docs/build/unreleased/986.rst b/docs/build/unreleased/986.rst new file mode 100644 index 00000000..6834d9d1 --- /dev/null +++ b/docs/build/unreleased/986.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, environment + :tickets: 986 + + The ``fileConfig()`` line in the ``env.py`` templates is now conditional on + ``Config.config_file_name`` not being None. +