Opened 15 years ago
Closed 14 years ago
#11481 closed Uncategorized (duplicate)
loaddata doesn't return the proper exit code on error
Reported by: | Justin Lilly | Owned by: | Justin Lilly |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | loaddata commands |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When loaddata errors, it doesn't return a proper error code. Instead, it just return
s.
Attachments (2)
Change History (6)
by , 15 years ago
Attachment: | loaddata_proper_err_code.diff added |
---|
comment:1 by , 15 years ago
Keywords: | loaddata commands added |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
This looks like a valid point. There are several other places in that command that should do the same thing, i.e. http://code.djangoproject.com/browser/django/trunk/django/core/management/commands/loaddata.py#L141, http://code.djangoproject.com/browser/django/trunk/django/core/management/commands/loaddata.py#L181
Why print the errors and not raise them in these cases, let python return the error code?
by , 15 years ago
Attachment: | loaddata_patch_ver_2.diff added |
---|
comment:2 by , 15 years ago
Patch needs improvement: | unset |
---|
I think the reason for printing the error messages and not returning exceptions is that we want to run the rollbacks. This could be fixed with a finally statement, but requires mucking with the code structure more. This seems like the simplest things that works.
I've also added another patch which corrects the other places where an error is printed, but not returning the right status code.
comment:3 by , 15 years ago
...or you could raise django.core.management.CommandError and let it raise through the whole stack. It would make the manage.py to exit with exit status 1.
comment:4 by , 14 years ago
Resolution: | → duplicate |
---|---|
Severity: | → Normal |
Status: | new → closed |
Type: | → Uncategorized |
Dupe of #10200.
Patch which uses sys.exit(1) instead of return.