2121    iNaT ,
2222    parsing ,
2323)
24- from  pandas .compat  import  WASM 
24+ from  pandas .compat  import  (
25+     PY314 ,
26+     WASM ,
27+ )
2528from  pandas .errors  import  (
2629    OutOfBoundsDatetime ,
2730    OutOfBoundsTimedelta ,
5760    r"alongside this." 
5861)
5962
63+ if  PY314 :
64+     NOT_99  =  ", not 99" 
65+     DAY_IS_OUT_OF_RANGE  =  (
66+         r"day \d{1,2} must be in range 1\.\.\d{1,2} for " 
67+         r"month \d{1,2} in year \d{4}" 
68+     )
69+ else :
70+     NOT_99  =  "" 
71+     DAY_IS_OUT_OF_RANGE  =  "day is out of range for month" 
72+ 
6073
6174class  TestTimeConversionFormats :
6275    def  test_to_datetime_readonly (self , writable ):
@@ -1378,7 +1391,7 @@ def test_datetime_invalid_scalar(self, value, format):
13781391                r'^Given date string "a" not likely a datetime$' ,
13791392                r'^unconverted data remains when parsing with format "%H:%M:%S": "9". ' 
13801393                f"{ PARSING_ERR_MSG }  ,
1381-                 r "^second must be in 0..59: 00:01:99$"
1394+                 rf "^second must be in 0..59{ NOT_99 } 
13821395            ]
13831396        )
13841397        with  pytest .raises (ValueError , match = msg ):
@@ -1430,7 +1443,7 @@ def test_datetime_invalid_index(self, values, format):
14301443                f"{ PARSING_ERR_MSG }  ,
14311444                r'^unconverted data remains when parsing with format "%H:%M:%S": "9". ' 
14321445                f"{ PARSING_ERR_MSG }  ,
1433-                 r "^second must be in 0..59: 00:01:99$"
1446+                 rf "^second must be in 0..59{ NOT_99 } 
14341447            ]
14351448        )
14361449        with  pytest .raises (ValueError , match = msg ):
@@ -2857,7 +2870,10 @@ def test_day_not_in_month_coerce(self, cache, arg, format):
28572870        assert  isna (to_datetime (arg , errors = "coerce" , format = format , cache = cache ))
28582871
28592872    def  test_day_not_in_month_raise (self , cache ):
2860-         msg  =  "day is out of range for month: 2015-02-29" 
2873+         if  PY314 :
2874+             msg  =  "day 29 must be in range 1..28 for month 2 in year 2015: 2015-02-29" 
2875+         else :
2876+             msg  =  "day is out of range for month: 2015-02-29" 
28612877        with  pytest .raises (ValueError , match = msg ):
28622878            to_datetime ("2015-02-29" , errors = "raise" , cache = cache )
28632879
@@ -2867,12 +2883,12 @@ def test_day_not_in_month_raise(self, cache):
28672883            ( 
28682884                "2015-02-29" , 
28692885                "%Y-%m-%d" , 
2870-                 f"^day is out of range for month . { PARSING_ERR_MSG }  , 
2886+                 f"^{ DAY_IS_OUT_OF_RANGE } { PARSING_ERR_MSG }  , 
28712887            ), 
28722888            ( 
28732889                "2015-29-02" , 
28742890                "%Y-%d-%m" , 
2875-                 f"^day is out of range for month . { PARSING_ERR_MSG }  , 
2891+                 f"^{ DAY_IS_OUT_OF_RANGE } { PARSING_ERR_MSG }  , 
28762892            ), 
28772893            ( 
28782894                "2015-02-32" , 
@@ -2889,12 +2905,12 @@ def test_day_not_in_month_raise(self, cache):
28892905            ( 
28902906                "2015-04-31" , 
28912907                "%Y-%m-%d" , 
2892-                 f"^day is out of range for month . { PARSING_ERR_MSG }  , 
2908+                 f"^{ DAY_IS_OUT_OF_RANGE } { PARSING_ERR_MSG }  , 
28932909            ), 
28942910            ( 
28952911                "2015-31-04" , 
28962912                "%Y-%d-%m" , 
2897-                 f"^day is out of range for month . { PARSING_ERR_MSG }  , 
2913+                 f"^{ DAY_IS_OUT_OF_RANGE } { PARSING_ERR_MSG }  , 
28982914            ), 
28992915        ], 
29002916    ) 
0 commit comments