This code for displaying WooCommerce custom attributes within a page seems to work sometimes, but as I said, throws error after editing and re-saving the page with the shortcode in it.

I've tried changing the setting: 'my code uses PHP echo' to 'return', but it seems to work the same either way (I would think 'echo' would apply here).

I get the php error on a white screen. If I reopen the page editor on another browser tab the page changes actually saved properly, and the page displays the WooCommerce attributes on the page as expected.