Opened 5 years ago
Last modified 5 years ago
#30728 closed Bug
Django urls patterns resolver shadowing exceptions thrown everywhere else — at Initial Version
Reported by: | Ariel Torti | Owned by: | nobody |
---|---|---|---|
Component: | Utilities | Version: | 2.2 |
Severity: | Release blocker | Keywords: | |
Cc: | Tom Forbes | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The new version of django somehow captures all the exceptions ocurred while parsing the urlpatterns.
How to reproduce:
- Create a django project
- Create a an app
app/views.py
from django.shortcuts import render class MyCustomExceptionShadowed(Exception): pass raise MyCustomExceptionShadowed('I have a description of your error') # Create your views here. def myview(request): pass
urls.py
from django.contrib import admin from django.urls import path from bugtest import views urlpatterns = [ path('', views.myview), path('admin/', admin.site.urls), ]
When running the server I get
django.core.exceptions.ImproperlyConfigured: The included URLconf 'bug.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
When in fact I expect it to say
File "/home/ariel-nt/Desktop/test/bug/bugtest/views.py", line 6, in <module> raise MyCustomExceptionShadowed('I have a description of your error') bugtest.views.MyCustomExceptionShadowed: I have a description of your error
I tested this with django 2.1 and it works as expected, so I'll now try to find the root cause of the error and give an update here
Note:
See TracTickets
for help on using tickets.