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

yaml.load() deprecation warning: YAMLLoadWarning #216

Closed
sablanchard opened this issue Mar 26, 2019 · 3 comments
Closed

yaml.load() deprecation warning: YAMLLoadWarning #216

sablanchard opened this issue Mar 26, 2019 · 3 comments

Comments

@sablanchard
Copy link
Contributor

Getting yaml.load() deprecation warning:

YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.

can be fixed with for example:

from yaml import CLoader as Loader, CDumper as Dumper

d= yaml.load(f, Loader=Loader)
@cvanoli
Copy link

cvanoli commented Apr 8, 2019

Another way to solve this is to replace yaml.load() by yaml.safe_load()

@smmaurer
Copy link
Member

Same problem as UDST/zone_model#17, more info at https://msg.pyyaml.org/load.

Looks like replacing yaml.load() with yaml.full_load() will definitely not break anything, because that's the current default loader.

Using yaml.safe_load() would probably work too, because as far as i can tell we're only using yaml to store Python dicts and lists (urbansim/utils/yamlio.py).

The only reference i can find for the different between "safe" and "full" loading is in the PyYaml code itself. It looks like "full" includes support for some python-specific data types like class instances.

My inclination would be to use safe_load() going forward, but perhaps use full_load() for updating older code, just to be certain we don't break anything that depends on the urbansim utilities..

@smmaurer
Copy link
Member

Fixed in PR #224.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants