Odd Behavior with Standard Loader and Scientific Notation

Issue #2 new
Eric Cousieau
created an issue

I'm noticing some odd behavior with PyYaml v3.10 (from Ubuntu 12.04 repos) regarding scientific notation, and could not find anything about it in the old PyYAML issue tracker.

I expected the following string to be converted to floats, but not all of them get there:

In [47]: yaml.load('[350e1, 350e-1, 350.e1, 350.e-1, 1e2, 1.e-2, 1e12, 1.e-12, 1e-12]')
Out[47]: ['350e1', '350e-1', '350.e1', 35.0, '1e2', 0.01, '1e12', 1e-12, '1e-12']

In [48]: print yaml.__version__

I parsed the same string with yaml-cpp and SnakeYaml (default loaders / parsers) and they produced all floats.

Comments (2)

  1. Dan Blanchard

    I also wanted to add that this is still present in 3.11.

    In [3]: yaml.load("1e2")
    Out[3]: '1e2'
    In [4]: yaml.load("100")
    Out[4]: 100
    In [5]: yaml.__version__
    Out[5]: '3.11'
  2. Log in to comment