mfenniak/pg8000 — Issue #10: Empty array issue
Author: franklx
Created: 2011-11-03 20:41:33+00:00
State: open

SELECTing an array field (with any primitive type into) raises an exception:

[03/Nov/2011:21:17:23] HTTP Traceback (most recent call last):
...
File "pg8000/types.py", line 442, in array_recv
element_len, = struct.unpack("!i", data[:4])
error: unpack str size too short for format

This is caused by the "data" variabile containing an empty string.

A quick but working fix could be the following:

```python
if len(data):
element_len, = struct.unpack("!i", data[:4])
else:
element_len = -1
```