Fix stacktrace in Module.get_attribute example

Closes #2522.