#5212 TypeError: not all arguments converted during string formatting by using Python 3.8.12
Opened 2 years ago by mzch. Modified 2 years ago

I tried to install another Pagure instance by using Python 3.8.12 and encountered the following error.

Sep  6 19:34:56 la web.sh[1072927]: 2021-09-06 19:34:56,142 [ERROR] pagure.flask_app: Error while processing request
Sep  6 19:34:56 la web.sh[1072927]: Traceback (most recent call last):
Sep  6 19:34:56 la web.sh[1072927]:   File "/srv/pagure/.pyenv/versions/3.8.7/lib/python3.8/site-packages/flask/app.py",
 line 2070, in wsgi_app
Sep  6 19:34:56 la web.sh[1072927]:     response = self.full_dispatch_request()
Sep  6 19:34:56 la web.sh[1072927]:   File "/srv/pagure/.pyenv/versions/3.8.7/lib/python3.8/site-packages/flask/app.py",
 line 1515, in full_dispatch_request
Sep  6 19:34:56 la web.sh[1072927]:     rv = self.handle_user_exception(e)
Sep  6 19:34:56 la web.sh[1072927]:   File "/srv/pagure/.pyenv/versions/3.8.7/lib/python3.8/site-packages/flask/app.py",
 line 1511, in full_dispatch_request
Sep  6 19:34:56 la web.sh[1072927]:     rv = self.preprocess_request()
Sep  6 19:34:56 la web.sh[1072927]:   File "/srv/pagure/.pyenv/versions/3.8.7/lib/python3.8/site-packages/flask/app.py",
 line 1857, in preprocess_request
Sep  6 19:34:56 la web.sh[1072927]:     rv = self.ensure_sync(func)()
Sep  6 19:34:56 la web.sh[1072927]:   File "/srv/pagure/pagure/pagure/ui/login.py", line 415, in _check_session_cookie
Sep  6 19:34:56 la web.sh[1072927]:     flask.g.session = pagure.lib.model_base.create_session(
Sep  6 19:34:56 la web.sh[1072927]:   File "/srv/pagure/pagure/pagure/lib/model_base.py", line 51, in create_session
Sep  6 19:34:56 la web.sh[1072927]:     db_url and db_url != ("%s" % SESSIONMAKER.kw["bind"].engine.url)
Sep  6 19:34:56 la web.sh[1072927]: TypeError: not all arguments converted during string formatting

Well, I could fix this error with the following patch.

--- model_base.py.bak   2021-09-06 20:12:35.330009357 -0700
+++ model_base.py   2021-09-06 20:13:07.250285585 -0700
@@ -48,7 +48,7 @@
     global SESSIONMAKER

     if SESSIONMAKER is None or (
-        db_url and db_url != ("%s" % SESSIONMAKER.kw["bind"].engine.url)
+        db_url and db_url != ('{}'.format(SESSIONMAKER.kw["bind"].engine.url))
     ):
         if db_url is None:
             raise ValueError("First call to create_session needs db_url")

Sep 6 19:34:56 la web.sh[1072927]: File "/srv/pagure/pagure/pagure/lib/model_base.py", line 51, in create_session
Sep 6 19:34:56 la web.sh[1072927]: db_url and db_url != ("%s" % SESSIONMAKER.kw["bind"].engine.url)
Sep 6 19:34:56 la web.sh[1072927]: TypeError: not all arguments converted during string formatting

  • db_url and db_url != ("%s" % SESSIONMAKER.kw["bind"].engine.url)
  • db_url and db_url != ('{}'.format(SESSIONMAKER.kw["bind"].engine.url))

This is weird, it would mean that SESSIONMAKER isn't bound to an engine. Could
it be that your instance had troubles reading its config file?

I can't find SESSIONMAKER in sample config or other files.
How can I put it. in config file?
I put DB_URL in config file as below:

DB_URL = 'postgresql://pagure:password@localhost:5432/pagure'

I can't find SESSIONMAKER in sample config or other files.
How can I put it. in config file

It is not in the configuration file, it's a variable filled when
"create_session" is called.

It seems that config file is read successfully...?

Login to comment on this ticket.

Metadata