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

ast.Module signature change in Python 3.8.0a3 causes TypeError #1551

Closed
paihu opened this issue May 19, 2019 · 7 comments
Closed

ast.Module signature change in Python 3.8.0a3 causes TypeError #1551

paihu opened this issue May 19, 2019 · 7 comments
Labels
Milestone

Comments

@paihu
Copy link

paihu commented May 19, 2019

With Python 3.8.0a3 and Werkzeug 0.15.4, compiling the rule builders causes TypeError: required field "type_ignores" missing from Module. It sounds like ast.Module has a new required argument.

I think this is the same problem as beetbox/beets#3201 (comment)

flask run
 * Serving Flask app "flask_test.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Traceback (most recent call last):
  File "d:\tool\python\38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\tool\python\38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "d:\tool\python\38\Scripts\flask.exe\__main__.py", line 9, in <module>
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 906, in main
    cli.main(args=args, prog_name=name)
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 569, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "d:\tool\python\38\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "d:\tool\python\38\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "d:\tool\python\38\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "d:\tool\python\38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "d:\tool\python\38\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "d:\tool\python\38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 779, in run_command
    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 300, in __init__
    self._load_unlocked()
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 324, in _load_unlocked
    self._app = rv = self.loader()
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 381, in load_app
    app = locate_app(self, import_name, name)
  File "d:\tool\python\38\lib\site-packages\flask\cli.py", line 236, in locate_app
    __import__(module_name)
  File "D:\flask_test.py", line 3, in <module>
    app = Flask(__name__)
  File "d:\tool\python\38\lib\site-packages\flask\app.py", line 559, in __init__
    self.add_url_rule(
  File "d:\tool\python\38\lib\site-packages\flask\app.py", line 67, in wrapper_func
    return f(self, *args, **kwargs)
  File "d:\tool\python\38\lib\site-packages\flask\app.py", line 1217, in add_url_rule
    self.url_map.add(rule)
  File "d:\tool\python\38\lib\site-packages\werkzeug\routing.py", line 1388, in add
    rule.bind(self)
  File "d:\tool\python\38\lib\site-packages\werkzeug\routing.py", line 730, in bind
    self.compile()
  File "d:\tool\python\38\lib\site-packages\werkzeug\routing.py", line 794, in compile
    self._build = self._compile_builder(False).__get__(self, None)
  File "d:\tool\python\38\lib\site-packages\werkzeug\routing.py", line 951, in _compile_builder
    code = compile(module, "<werkzeug routing>", "exec")
TypeError: required field "type_ignores" missing from Module
@paihu paihu changed the title Crashes on Python 3.8.0a3 in 0. Crashes on Python 3.8.0a3 in 0.15.3 and 0.15.4 May 19, 2019
@davidism
Copy link
Member

This needs to be reported to CPython as an undocumented and backwards-incompatible API change in the standard library.

@davidism davidism changed the title Crashes on Python 3.8.0a3 in 0.15.3 and 0.15.4 ast.Module signature change in Python 3.8.0a3 causes TypeError May 19, 2019
@davidism
Copy link
Member

@asottile What are your thoughts? I'm not sure we should fix this yet, Python 3.8 has been causing then fixing random issues for quite a while.

@davidism
Copy link
Member

Looks like this was reported in CPython https://bugs.python.org/issue35894 and the resolution was that downstream code should add a if sys.version_info >= (3, 8). 😒

@asottile
Copy link
Contributor

😡 what a wacky resolution -- I'll make a more portable fix for this, coming right up!

@brainix
Copy link

brainix commented Oct 15, 2019

Thank you for the quick turnaround on this and many other issues. Python 3.8.0 final has been released. Can we get a Werkzeug 0.15.5 release?

benpbrown added a commit to lightstep/hipster-shop that referenced this issue Mar 16, 2020
3.8 has a problem with the pinned werkzeug version. Instead of messing
with pip requirements, just downgrade Python.

Issue: pallets/werkzeug#1551

+ STATUSCODE=200
+ test 200 -ne 200
+ locust --host=http://frontend:80 --no-web -c 500
Traceback (most recent call last):
  File "/usr/local/bin/locust", line 11, in <module>
    load_entry_point('locustio==0.8.1', 'console_scripts', 'locust')()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.8/site-packages/locust/main.py", line 14, in <module>
    from . import events, runners, web
  File "/usr/local/lib/python3.8/site-packages/locust/web.py", line 27, in <module>
    app = Flask(__name__)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 558, in __init__
    self.add_url_rule(
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 66, in wrapper_func
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1216, in add_url_rule
    self.url_map.add(rule)
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 1386, in add
    rule.bind(self)
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 730, in bind
    self.compile()
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 794, in compile
    self._build = self._compile_builder(False).__get__(self, None)
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 945, in _compile_builder
    code = compile(module, "<werkzeug routing>", "exec")
TypeError: required field "type_ignores" missing from Module
benpbrown added a commit to lightstep/hipster-shop that referenced this issue Mar 16, 2020
3.8 has a problem with the pinned werkzeug version. Instead of messing
with pip requirements, just downgrade Python.

Issue: pallets/werkzeug#1551

+ STATUSCODE=200
+ test 200 -ne 200
+ locust --host=http://frontend:80 --no-web -c 500
Traceback (most recent call last):
  File "/usr/local/bin/locust", line 11, in <module>
    load_entry_point('locustio==0.8.1', 'console_scripts', 'locust')()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.8/site-packages/locust/main.py", line 14, in <module>
    from . import events, runners, web
  File "/usr/local/lib/python3.8/site-packages/locust/web.py", line 27, in <module>
    app = Flask(__name__)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 558, in __init__
    self.add_url_rule(
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 66, in wrapper_func
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1216, in add_url_rule
    self.url_map.add(rule)
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 1386, in add
    rule.bind(self)
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 730, in bind
    self.compile()
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 794, in compile
    self._build = self._compile_builder(False).__get__(self, None)
  File "/usr/local/lib/python3.8/site-packages/werkzeug/routing.py", line 945, in _compile_builder
    code = compile(module, "<werkzeug routing>", "exec")
TypeError: required field "type_ignores" missing from Module
sebbacon added a commit to ebmdatalab/ebmbot that referenced this issue Jun 26, 2020
Werkzeug upgraded to fix underlying bug that this surfaces

pallets/werkzeug#1551
lljr added a commit to lljr/project2 that referenced this issue Jun 26, 2020
spk added a commit to spk/flask-recipes that referenced this issue Jul 5, 2020
@duhaime
Copy link

duhaime commented Aug 2, 2020

Does anyone have a workaround for this issue?

@davidism
Copy link
Member

davidism commented Aug 2, 2020

It was fixed in a subsequent release. Upgrade your version of Werkzeug.

hibariya added a commit to hibariya/subscription-use-cases that referenced this issue Sep 13, 2020
When I tried Python examples with Python 3.8.5, I got the following error:

    TypeError: required field "type_ignores" missing from Module

I updated the dependency since it seems the error is related to this issue:
pallets/werkzeug#1551
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants