Skip to content

Commit 0c774c7

Browse files
authored
fix empty string error in Printf (#50011)
* fix empty string error in Printf * Update runtests.jl * Update runtests.jl
1 parent c3d70e8 commit 0c774c7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stdlib/Printf/src/Printf.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ end
122122

123123
# parse format string
124124
function Format(f::AbstractString)
125-
isempty(f) && throw(InvalidFormatStringError("Format string must not be empty", f, 1, 1))
126125
bytes = codeunits(f)
127126
len = length(bytes)
128127
pos = 1

stdlib/Printf/test/runtests.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ end
339339
@test Printf.@sprintf("1%%2%%3") == "1%2%3"
340340
@test Printf.@sprintf("GAP[%%]") == "GAP[%]"
341341
@test Printf.@sprintf("hey there") == "hey there"
342-
@test_throws Printf.InvalidFormatStringError Printf.Format("")
343342
@test_throws Printf.InvalidFormatStringError Printf.Format("%+")
344343
@test_throws Printf.InvalidFormatStringError Printf.Format("%.")
345344
@test_throws Printf.InvalidFormatStringError Printf.Format("%.0")
@@ -488,6 +487,10 @@ end
488487
@test @sprintf("%d", 3//1) == "3"
489488
@test @sprintf("%d", Inf) == "Inf"
490489
@test @sprintf(" %d", NaN) == " NaN"
490+
491+
# 50011
492+
@test Printf.@sprintf("") == ""
493+
@test Printf.format(Printf.Format("")) == ""
491494
end
492495

493496
@testset "integers" begin

0 commit comments

Comments
 (0)