File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ Requires Python 3.9+
2020
2121### Fixes
2222
23+ [ #266 ] ( https://github.com/metomi/isodatetime/pull/234 ) :
24+ Fixed a bug causing unhelpful error messages when parsing a
25+ malformed time-point containing >1 letter "T".
26+
2327[ #234 ] ( https://github.com/metomi/isodatetime/pull/234 ) :
2428Fixed behaviour of adding a truncated TimePoint to a normal TimePoint.
2529
Original file line number Diff line number Diff line change @@ -439,7 +439,7 @@ def get_info(self, timepoint_string):
439439 time_zone_info = (
440440 self .process_time_zone_info ({}))
441441 time_info .update (time_zone_info )
442- else :
442+ elif len ( date_time_time_zone ) == 2 :
443443 date , time_time_zone = date_time_time_zone
444444 if not date and self .allow_truncated :
445445 keys = (None , "truncated" , "" )
@@ -501,6 +501,8 @@ def get_info(self, timepoint_string):
501501 parsed_expr += parser_spec .TIME_DESIGNATOR + (
502502 time_expr + time_zone_expr )
503503 time_info .update (time_zone_info )
504+ else :
505+ raise ISO8601SyntaxError ('time' , timepoint_string )
504506 return date_info , time_info , parsed_expr
505507
506508 def process_time_zone_info (self , time_zone_info = None ):
Original file line number Diff line number Diff line change 2323import random
2424
2525from metomi .isodatetime .data import TimePoint , Duration , get_days_since_1_ad
26+ from metomi .isodatetime .parsers import TimePointParser
27+ from metomi .isodatetime .exceptions import ISO8601SyntaxError
2628
2729
2830def daterange (start_date , end_date ):
@@ -123,3 +125,12 @@ def _test_timepoint(test_year):
123125 test_data .get_calendar_date (),
124126 test_data .get_hour_minute_second ()]
125127 assert test_data == ctrl_data
128+
129+
130+ def test_invalid_point ():
131+ """Check that invalid points return a sensible failure.
132+ """
133+ bad = 'STARTTIMET0000Z'
134+ tpp = TimePointParser ()
135+ with pytest .raises (ISO8601SyntaxError , match = bad ):
136+ tpp .parse (bad )
You can’t perform that action at this time.
0 commit comments