shipping_checkout_api() in shipping.module is called when generating the paypal page. $txn->ship is an array and the function works.

On the page ?q=admin/store/invoice/txnid_28/edit (Edit transaction page) $txn->ship is an object and the function fails.

The statement in question is: $txn->misc[$key]->price = $txn->ship['cost'];

If it is changed to $txn->misc[$key]->price = $txn->ship->cost; then shipping costs are not included in the paypal price but the transaction edit page works.