Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidict version 4.7.0 breaks Sanic #1729

Closed
omab opened this issue Dec 10, 2019 · 14 comments
Closed

Multidict version 4.7.0 breaks Sanic #1729

omab opened this issue Dec 10, 2019 · 14 comments

Comments

@omab
Copy link

omab commented Dec 10, 2019

Describe the bug
multidict project just released (1 hour ago) their version 4.7.0 (https://pypi.org/project/multidict/#history), this includes a change that breaks Sanic Header class definition.

----> 1 import sanic

/usr/local/lib/python3.7/site-packages/sanic/__init__.py in <module>
      1 from sanic.__version__ import __version__
----> 2 from sanic.app import Sanic
      3 from sanic.blueprints import Blueprint
      4 
      5 

/usr/local/lib/python3.7/site-packages/sanic/app.py in <module>
     16 
     17 from sanic import reloader_helpers
---> 18 from sanic.asgi import ASGIApp
     19 from sanic.blueprint_group import BlueprintGroup
     20 from sanic.config import BASE_LOGO, Config

/usr/local/lib/python3.7/site-packages/sanic/asgi.py in <module>
     20 import sanic.app  # noqa
     21 
---> 22 from sanic.compat import Header
     23 from sanic.exceptions import InvalidUsage, ServerError
     24 from sanic.log import logger

/usr/local/lib/python3.7/site-packages/sanic/compat.py in <module>
      2 
      3 
----> 4 class Header(CIMultiDict):
      5     def get_all(self, key):
      6         return self.getall(key, default=[])

TypeError: type 'multidict._multidict.CIMultiDict' is not an acceptable base type

Code snippet

$ pip install -U multidict==4.7.0
$ python -m sanic

Expected behavior
Sanic module imports correctly.

Environment (please complete the following information):

  • OS: Linux (docker)
  • Version: 19.9.0
  • Python: 3.7.3

Additional context
No extra context

@optroodt
Copy link

optroodt commented Dec 10, 2019

I get the same thing in my CI builds:

    from sanic.response import HTTPResponse
/usr/local/lib/python3.6/site-packages/sanic/__init__.py:2: in <module>
    from sanic.app import Sanic
/usr/local/lib/python3.6/site-packages/sanic/app.py:18: in <module>
    from sanic.asgi import ASGIApp
/usr/local/lib/python3.6/site-packages/sanic/asgi.py:22: in <module>
    from sanic.compat import Header
/usr/local/lib/python3.6/site-packages/sanic/compat.py:4: in <module>
    class Header(CIMultiDict):
E   TypeError: type 'multidict._multidict.CIMultiDict' is not an acceptable base type

Environment (please complete the following information):

  • OS: Linux (docker)
  • Version: 19.9.0
  • Python: 3.6.9

@omab
Copy link
Author

omab commented Dec 10, 2019

Downgrading to multidict==4.6.1 fixes the problem.

@qwesda
Copy link
Contributor

qwesda commented Dec 11, 2019

The error occurs because the cimultidict_type does not have the Py_TPFLAGS_BASETYPE flag set ...

I reported the issue aio-libs/multidict#416 and made a PR I also made a PR aio-libs/multidict#417 ... a lot of boilerplate for 44 bytes

@greatvovan
Copy link

Only the latest Sanic version 19.9.0 fail as well as 19.6.3. Version 19.6.2 (and older) works well with multidict==4.7.0.

@greatvovan
Copy link

Also, interestingly, both 19.9.0 and 19.6.3 work on my machine with my local Python 3.8.0 (built with pyenv, Mac OS 10.15), but both don't work in the official Python Docker image 3.8.

@bidyottama278
Copy link

bidyottama278 commented Dec 11, 2019

Here am also getting the same issue

File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/src/app.py", line 1, in <module>
    from sanic import Sanic, response
  File "/root/.local/share/virtualenvs/lib/python3.7/site-packages/sanic/__init__.py", line 2, in <module>    from sanic.app import Sanic
  File "/root/.local/share/virtualenvs/lib/python3.7/site-packages/sanic/app.py", line 18, in <module>
    from sanic.asgi import ASGIApp
  File "/root/.local/share/virtualenvs/lib/python3.7/site-packages/sanic/asgi.py", line 22, in <module>
    from sanic.compat import Header
  File "/root/.local/share/virtualenvs/lib/python3.7/site-packages/sanic/compat.py", line 4, in <module>
    class Header(CIMultiDict):
TypeError: type 'multidict._multidict.CIMultiDict' is not an acceptable base type

am using python 3.7.2 version and sanic=* is in my pipfile
which version of sanic i should use here ?

@aowji
Copy link

aowji commented Dec 11, 2019

Sanic version 19.6.2 work on my machine

@jkanche
Copy link

jkanche commented Dec 11, 2019

downgrading multidict to 4.6.1 fixed the problem for me!

@qwesda
Copy link
Contributor

qwesda commented Dec 11, 2019

My PR is merged - hope 4.7.1 will come out soon

@bidyottama278
Copy link

bidyottama278 commented Dec 12, 2019

Thanks all for these responses.. multidict 4.6.1 is working for me.

@omab
Copy link
Author

omab commented Dec 12, 2019

@qwesda, I confirm the error is gone with the new multidict==4.7.1.

Thanks!

@omab omab closed this as completed Dec 12, 2019
@balakumar98
Copy link

Downgrading to multidict==4.6.1 fixes the problem.

requires 4.7.1 or above

@ahopkins
Copy link
Member

Has anyone run Sanic with multidict==4.7.1?

@omab
Copy link
Author

omab commented Dec 31, 2019

@ahopkins, I'm using it, no issues so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants