Skip to content

Commit badc8fe

Browse files
committed
fix empty bytes object construction
1 parent d677540 commit badc8fe

File tree

15 files changed

+45
-70
lines changed

15 files changed

+45
-70
lines changed

dotnet/Razorvine.Pickle/Benchmarks/Benchmarks.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
11-
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.5" />
10+
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
11+
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.5" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

dotnet/Razorvine.Pickle/Pickle/Pickle.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<Authors>Irmen de Jong</Authors>
99
<Product>Python pickle serialization protocol library for .NET</Product>
1010
<PackageId>Razorvine.Pickle</PackageId>
11-
<Version>1.3.0</Version>
12-
<AssemblyVersion>1.3.0.0</AssemblyVersion>
13-
<FileVersion>1.3.0.0</FileVersion>
11+
<Version>1.4.0</Version>
12+
<AssemblyVersion>1.4.0.0</AssemblyVersion>
13+
<FileVersion>1.4.0.0</FileVersion>
1414
<SignAssembly>true</SignAssembly>
1515
<DelaySign>false</DelaySign>
1616
<AssemblyOriginatorKeyFile>Pickle.snk</AssemblyOriginatorKeyFile>
@@ -25,6 +25,6 @@
2525
<PackageReleaseNotes>Stand alone pickle library.</PackageReleaseNotes>
2626
</PropertyGroup>
2727
<ItemGroup>
28-
<PackageReference Include="System.Memory" Version="4.5.4" />
28+
<PackageReference Include="System.Memory" Version="4.5.5" />
2929
</ItemGroup>
3030
</Project>

dotnet/Razorvine.Pickle/Pickle/Pickle/Objects/ByteArrayConstructor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ public class ByteArrayConstructor : IObjectConstructor {
1515
public object construct(object[] args) {
1616
// args for bytearray constructor: [ String string, String encoding ]
1717
// args for bytearray constructor (from python3 bytes): [ ArrayList ] or just [byte[]] (when it uses BINBYTES opcode)
18-
if (args.Length != 1 && args.Length != 2)
18+
// or, zero arguments: empty bytearray.
19+
if (args.Length>2)
1920
throw new PickleException("invalid pickle data for bytearray; expected 1 or 2 args, got "+args.Length);
2021

22+
if (args.Length == 0)
23+
return new byte[]{};
24+
2125
if(args.Length==1) {
2226
if(args[0] is byte[]) {
2327
return args[0];

dotnet/Razorvine.Pickle/UnitTests/Pickle/UnpicklerTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,15 @@ public void TestBytesAndByteArray()
407407
Assert.Equal(Encoding.ASCII.GetBytes("ABCDEFGH"), (byte[])U(p3));
408408
}
409409

410+
[Fact]
411+
public void TestUnpickleEmptyBytes() {
412+
byte[] pickled = {
413+
128, 2, 99, 95, 95, 98, 117, 105, 108, 116, 105, 110, 95, 95, 10, 98, 121, 116, 101, 115, 10, 113, 0, 41, 82, 113, 1, 46
414+
};
415+
byte[] obj = (byte[]) (new Unpickler().loads(pickled));
416+
Assert.Empty(obj);
417+
}
418+
410419
[Fact]
411420
public void TestArray()
412421
{

dotnet/Razorvine.Pickle/UnitTests/UnitTests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<LangVersion>7.3</LangVersion>
88
</PropertyGroup>
99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
11-
<PackageReference Include="xunit" Version="2.4.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
11+
<PackageReference Include="xunit" Version="2.4.2" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>

java/.idea/compiler.xml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/.idea/libraries/Maven__junit_junit_4_13_1.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

java/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

java/.idea/misc.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/.idea/modules.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)