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

Fixed #12756: Improved error message when yaml module is missing. #1582

Conversation

rca
Copy link
Contributor

@rca rca commented Sep 6, 2013

Running dumpdata without pyyaml installed will now produce a useful error message:

[berto@scratch]$ python manage.py dumpdata --format=yaml
CommandError: Unable to serialize database: No module named yaml

This test makes sure an YAML import errors are communicated to the
caller rather than stating the serializer does not exist.
The serializer definitely exists, but the dependent yaml module may not
be installed.  The register_serializer() function will catch exceptions
and will stub in a fake serializer object that will raise the exception
when the serializer is used.
Moved the get_serializer() call within the condition that checks public
serializers.  This will allow exceptions other than
SerializerDoesNotExist to be raised in order to provide the caller with
useful information, e.g when pyyaml is not installed.
In order to verify the behavior of using the yaml serializer when yaml
is on the system, fake the ImportError when the serializer is being
registered.
When a BadSerializer instance is stubbed in for the yaml serializer,
make sure tests do not fail.
@rca
Copy link
Contributor Author

rca commented Sep 6, 2013

This PR replaces #1564.

freakboy3742 added a commit that referenced this pull request Sep 6, 2013
…r-error-message

Fixed #12756: Improved error message when yaml module is missing.
@freakboy3742 freakboy3742 merged commit 4f5faa1 into django:master Sep 6, 2013
freakboy3742 added a commit that referenced this pull request Sep 7, 2013
…erializer-error-message

Fixed #12756: Improved error message when yaml module is missing.

Backport of 4f5faa1 from master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants