Ticket #149 (new defect)

Opened 4 years ago

Throws wrong ValueError exception on bad time stamps

Reported by: f_d_c_-alquiler@… Owned by: xi
Priority: normal Component: pyyaml
Severity: normal Keywords: ValueError, YAMLError


If a timestamp is badly formatted construct_yaml_timestamp() throws an uncaught ValueError? instead of yaml.YAMLError:

>>> yaml.safe_load("2009-13-11")
Traceback (most recent call last):
  File "<pyshell#4>", line 2, in <module>
  File "C:\Python26\lib\site-packages\yaml\", line 75, in safe_load
    return load(stream, SafeLoader)
  File "C:\Python26\lib\site-packages\yaml\", line 58, in load
    return loader.get_single_data()
  File "C:\Python26\lib\site-packages\yaml\", line 44, in get_single_data
    return self.construct_document(node)
  File "C:\Python26\lib\site-packages\yaml\", line 48, in construct_document
    data = self.construct_object(node)
  File "C:\Python26\lib\site-packages\yaml\", line 93, in construct_object
    data = constructor(self, node)
  File "C:\Python26\lib\site-packages\yaml\", line 318, in construct_yaml_timestamp
    return, month, day)
ValueError: month must be in 1..12


  • Python 2.6.4 on Windows XP
  • PyYAML-3.09-py2.5.exe

I think the function should include something like this:

    return, month, day)
except ValueError:
    raise ConstructorError(None,None,"inappropriate date value",node.start_mark)

Thank you.



Add a comment

Modify Ticket

Change Properties
<Author field>
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from xi. Next status will be 'new'
The owner will be changed from xi to anonymous. Next status will be 'assigned'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.