From 0c774c7fb8815cc700e2828066d3e9053f7c3a11 Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Sat, 3 Jun 2023 08:13:14 +0300 Subject: [PATCH] fix empty string error in Printf (#50011) * fix empty string error in Printf * Update runtests.jl * Update runtests.jl --- stdlib/Printf/src/Printf.jl | 1 - stdlib/Printf/test/runtests.jl | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/Printf/src/Printf.jl b/stdlib/Printf/src/Printf.jl index 8600af8227d7f..cb336a8d9c18b 100644 --- a/stdlib/Printf/src/Printf.jl +++ b/stdlib/Printf/src/Printf.jl @@ -122,7 +122,6 @@ end # parse format string function Format(f::AbstractString) - isempty(f) && throw(InvalidFormatStringError("Format string must not be empty", f, 1, 1)) bytes = codeunits(f) len = length(bytes) pos = 1 diff --git a/stdlib/Printf/test/runtests.jl b/stdlib/Printf/test/runtests.jl index 96d61b61d02e3..33970f78648e2 100644 --- a/stdlib/Printf/test/runtests.jl +++ b/stdlib/Printf/test/runtests.jl @@ -339,7 +339,6 @@ end @test Printf.@sprintf("1%%2%%3") == "1%2%3" @test Printf.@sprintf("GAP[%%]") == "GAP[%]" @test Printf.@sprintf("hey there") == "hey there" - @test_throws Printf.InvalidFormatStringError Printf.Format("") @test_throws Printf.InvalidFormatStringError Printf.Format("%+") @test_throws Printf.InvalidFormatStringError Printf.Format("%.") @test_throws Printf.InvalidFormatStringError Printf.Format("%.0") @@ -488,6 +487,10 @@ end @test @sprintf("%d", 3//1) == "3" @test @sprintf("%d", Inf) == "Inf" @test @sprintf(" %d", NaN) == " NaN" + + # 50011 + @test Printf.@sprintf("") == "" + @test Printf.format(Printf.Format("")) == "" end @testset "integers" begin