pyyaml icon indicating copy to clipboard operation
pyyaml copied to clipboard

Is there a way to stop/remove constructors?

Open driesceuppens opened this issue 3 years ago • 2 comments

For an application, I would need an extra safe version of the yaml.safe_load() that can't return datetime objects or bytes. Is there any way to stop this without sanitizing input?

This is for python 3.8

driesceuppens avatar Aug 27 '21 22:08 driesceuppens

you could use the BaseLoader. That loads everything as a string. Would that work for you? yaml.load(..., Loader=yaml.BaseLoader)

perlpunk avatar Aug 27 '21 23:08 perlpunk

That would not exactly be what I need since access to dicts, lists, sets and other base python types is needed.

driesceuppens avatar Aug 27 '21 23:08 driesceuppens