anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: django-extensions/django-extensions
Issue: print_user_for_session doesn't look for USERNAME_FIELD attr on custom User models

Throws following error when using custom user model.

```
AttributeError: 'ProfileUser' object has no attribute 'username'
```

(django>=1.5 issue)


Changed files:
django_extensions/management/commands/print_user_for_session.py

diff --git a/django_extensions/management/commands/print_user_for_session.py b/django_extensions/management/commands/print_user_for_session.py
index d61059fc..6189d2ae 100644
--- a/django_extensions/management/commands/print_user_for_session.py
+++ b/django_extensions/management/commands/print_user_for_session.py
@@ -62,5 +62,10 @@ class Command(BaseCommand):
             print("No user associated with that id.")
             return
 
-        for key in ['username', 'email', 'first_name', 'last_name']:
+        username_field = 'username'
+
+        if hasattr(User, 'USERNAME_FIELD') and User.USERNAME_FIELD is not None:
+            username_field = User.USERNAME_FIELD
+
+        for key in [username_field, 'email', 'first_name', 'last_name']:
             print("%s: %s" % (key, getattr(user, key)))
Repository: pycqa/isort
Issue: Infinite loop on unclosed parenthesis

If I run isort (5.10.1 or `main` at c6a41965247a858a0afd848fbebfca18b8983917) on this invalid file with an unclosed parenthesis, it goes into a 100% CPU infinite loop:

```python3
from os import (
```

Changed files:
tests/unit/test_isort.py, isort/core.py

diff --git a/isort/core.py b/isort/core.py
index e9a2977b..9dfaf70f 100644
--- a/isort/core.py
+++ b/isort/core.py
@@ -7,7 +7,7 @@ import isort.literal
 from isort.settings import DEFAULT_CONFIG, Config
 
 from . import output, parse
-from .exceptions import FileSkipComment
+from .exceptions import ExistingSyntaxErrors, FileSkipComment
 from .format import format_natural, remove_whitespace
 from .settings import FILE_SKIP_COMMENTS
 
@@ -303,6 +303,10 @@ def process(
                         else:
                             while ")" not in stripped_line:
                                 line = input_stream.readline()
+
+                                if not line:  # end of file without closing parenthesis
+                                    raise ExistingSyntaxErrors("Parenthesis is not closed")
+
                                 stripped_line = line.strip().split("#")[0]
                                 import_statement += line
 
diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py
index 293b99be..55de0f20 100644
--- a/tests/unit/test_isort.py
+++ b/tests/unit/test_isort.py
@@ -5562,3 +5562,21 @@ def test_find_imports_in_stream() -> None:
     test_input = NonSeekableTestStream("import m2\\n" "import m1\\n" "not_import = 7")
     identified_imports = list(map(str, api.find_imports_in_stream(test_input)))
     assert identified_imports == [":1 import m2", ":2 import m1"]
+
+
+def test_infinite_loop_in_unmatched_parenthesis() -> None:
+    test_input = "from os import ("
+
+    # ensure a syntax error is raised for unmatched parenthesis
+    with pytest.raises(ExistingSyntaxErrors):
+        isort.code(test_input)
+
+    test_input = """from os import (
+    path,
+
+    walk
+)
+"""
+
+    # ensure other cases are handled correctly
+    assert isort.code(test_input) == "from os import path, walk\\n"