Skip to content

Can't debug Falcon in Python 3.10 #2112

@YossiTamari

Description

@YossiTamari

At least in PyCharm, when running in debug mode (so with Type Checking on), in Python 3.10 specifically, importing falcon adds a a property called dict to Python's collections. The property is a dict of media type handlers.
That causes a crash later when collections tries to do dict(...).
(Tested in Falcon 3.1.0: falcon-3.1.0-cp310-cp310-macosx_10_15_x86_64.whl)

To reproduce simply debug this code:

import collections
import falcon
print(collections.dict)

The output when running with a debugger is:

{'application/json': <falcon.media.json.JSONHandler object at 0x120e59ba0>, 'application/x-www-form-urlencoded': <falcon.media.urlencoded.URLEncodedFormHandler object at 0x120e59c00>}

When running without a debugger it correctly raises AttributeError: module 'collections' has no attribute 'dict'

Additional Information: This seems to happen inside falcon/__init__.py in the call to from falcon.app import API. Putting a breakpoint inside falcon.app did not work. For some reason, the debugger would not stop there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions