Skip to content

[Junie]: bizarre behavior with torch module's Attribute Error Junie#6

Open
junie-eap[bot] wants to merge 1 commit intomainfrom
junie-issue-4
Open

[Junie]: bizarre behavior with torch module's Attribute Error Junie#6
junie-eap[bot] wants to merge 1 commit intomainfrom
junie-issue-4

Conversation

@junie-eap
Copy link
Copy Markdown

@junie-eap junie-eap bot commented Apr 28, 2025

📌 Hey! This PR was made for you with Junie, the coding agent by JetBrains Early Access Preview

It's still learning, developing, and might make mistakes. Please make sure you review the changes before you accept them.
We’d love your feedback — join our Discord to share bugs, ideas: here.

📝 Original Issue Description

  Issue task:
  ### 🐛 Describe the bug

🐛 Describe the bug
when executing the following code:

import torch

class A(torch.nn.Module):
def init(self):
super().init()

@property
def foo(self):
    return self.bar # attr error

a = A()
print(a.foo)
I obtain

Traceback (most recent call last):
File "test.py", line 12, in
print(a.foo)
File "xxx/python3.8/site-packages/torch/nn/modules/module.py", line 1729, in getattr
raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'")
AttributeError: 'A' object has no attribute 'foo'
but the expected behavior would be AttributeError: 'A' object has no attribute 'bar'.

Versions

Versions
versions is seemingly irrelevant. Anyhow i use
[conda] torch 2.4.0+cu118 pypi_0 pypi

  Issue comments:
  No comments yet

📊 Junie Summary

A fix was implemented for torch.nn.Module to ensure properties raise the original AttributeError for missing attributes instead of incorrectly reporting the property itself as missing. The implementation is error-free, but testing was blocked by a module import error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants