-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check other ISO8601 datetimes for WARC/1.1 compliance. Re:#283
- Loading branch information
Showing
1 changed file
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9cd23ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@machawk1 this will change the exception behavior. Earlier, if a string was supplied that does not fit the specific format then
strptime
would have thrown an exception to the caller. Now, all thestrptime
-originated exceptions are suppressed and if the value matches none of the formats thend
will not be initialized, as a result thereturn
line will through a different type of exception when it will try to callstrftime
on an undefined object.9cd23ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibnesayeed That behavior is somewhat by-design but not yet handled. This is exhibited, for example, when variableSizedDates.warc is indexed. The exception thrown is
UnboundLocalError: local variable 'd' referenced before assignment
. Catching it in the present try-catch will not work, as the exception is thrown in the transformation step current inline with the return statement.How do you recommend we revise this? It is not yet complete (hence, not merged).
9cd23ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with the
UnboundLocalError
exception is that we are telling the caller about a variable local to this function that the caller has no control on. We should be throwing an exception to let the caller know that their string does not comply with any of the supported formats, which will essentially be aValueError
.