add assertion to catch failed attribute creation

This problem was surfaced by issue #268. We weren't doing a proper check for failed attribute creation in the attr method. This still fails and segaults, but the reason is now obvious.
Merge pull request #269 from polotek/attr-segfault-gh268

add assertion to catch failed attribute creation