litble/Multi-Docker-Eval huggingface dataset:
Repository: pallets-eco/flask-wtf (python)

Issue:
Update to Request.get_json() in Werkzeug 2.1.0 breaks empty forms
Similar to #510 - the get_json() change in Werkzeug 2.1.0 https://github.com/pallets/werkzeug/issues/2339 breaks any empty submitted form (not json).
From form.py:
   
```
 def wrap_formdata(self, form, formdata):
            if formdata is _Auto:
                if _is_submitted():
                    if request.files:
                        return CombinedMultiDict((request.files, request.form))
                    elif request.form:
                        return request.form
                    elif request.get_json():
                        return ImmutableMultiDict(request.get_json())
```


If the form is an empty ImmutableMultiDict - it falls into the get_json() code which is then checking that the content-type header has been set to application/json.

Possible solution would be to change elif request.get_json() to elif request.is_json()


Expected Behavior:

Empty form submits should be allowed as they were. In the case of an empty form - None should be returned from the wrapper.

Environment:

- Python version: 3.8
- Flask-WTF version: 1.0.0
- Flask version: 2.1



Discussion:

Patch:
diff --git a/src/flask_wtf/__init__.py b/src/flask_wtf/__init__.py
--- a/src/flask_wtf/__init__.py
+++ b/src/flask_wtf/__init__.py
@@ -5,4 +5,4 @@
 from .recaptcha import RecaptchaField
 from .recaptcha import RecaptchaWidget
 
-__version__ = "1.0.0"
+__version__ = "1.0.1.dev0"
diff --git a/src/flask_wtf/form.py b/src/flask_wtf/form.py
--- a/src/flask_wtf/form.py
+++ b/src/flask_wtf/form.py
@@ -56,7 +56,7 @@ def wrap_formdata(self, form, formdata):
                         return CombinedMultiDict((request.files, request.form))
                     elif request.form:
                         return request.form
-                    elif request.get_json():
+                    elif request.is_json:
                         return ImmutableMultiDict(request.get_json())
 
                 return None
diff --git a/src/flask_wtf/recaptcha/validators.py b/src/flask_wtf/recaptcha/validators.py
--- a/src/flask_wtf/recaptcha/validators.py
+++ b/src/flask_wtf/recaptcha/validators.py
@@ -30,7 +30,7 @@ def __call__(self, form, field):
         if current_app.testing:
             return True
 
-        if request.json:
+        if request.is_json:
             response = request.json.get("g-recaptcha-response", "")
         else:
             response = request.form.get("g-recaptcha-response", "")


Test patch:
diff --git a/tests/test_recaptcha.py b/tests/test_recaptcha.py
--- a/tests/test_recaptcha.py
+++ b/tests/test_recaptcha.py
@@ -80,7 +80,8 @@ def test_render_custom_args(app):
     app.config["RECAPTCHA_DATA_ATTRS"] = {"red": "blue"}
     f = RecaptchaForm()
     render = f.recaptcha()
-    assert "?key=%28value%29" in render
+    # new versions of url_encode allow more characters
+    assert "?key=(value)" in render or "?key=%28value%29" in render
     assert 'data-red="blue"' in render
Repository: pytest-dev/pytest-django (python)

Issue:
4.5.1: reset_sequences=True fails on MariaDB/MySQL
Firstly, thanks for maintaining such a powerful and useful testing library for Django.

On to the bug:

- OS: Windows 10
- Python: 3.9.1
- pytest-6.2.5
- py-1.11.0
- pluggy-1.0.0
- Django: 3.2.10

Example:

    @pytest.mark.django_db(reset_sequences=True)
    def test_reset_sequences():
        assert True

Output:

    ERROR my_test.py::test_reset_sequences - AssertionError: reset_sequences cannot be used on TestCase instances


Discussion:
It's missing `transaction=True`. Needs a better error message.

Did it work on pytest-django 4.4.0? If yes, then I'll make it work again.
Thanks for the fast response! Yes it works on 4.5.0

Patch:
diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py
--- a/pytest_django/fixtures.py
+++ b/pytest_django/fixtures.py
@@ -167,7 +167,7 @@ def _django_db_helper(
             serialized_rollback,
         ) = False, False, None, False
 
-    transactional = transactional or (
+    transactional = transactional or reset_sequences or (
         "transactional_db" in request.fixturenames
         or "live_server" in request.fixturenames
     )


Test patch:
diff --git a/tests/test_database.py b/tests/test_database.py
--- a/tests/test_database.py
+++ b/tests/test_database.py
@@ -287,11 +287,16 @@ def test_reset_sequences_disabled(self, request) -> None:
         marker = request.node.get_closest_marker("django_db")
         assert not marker.kwargs
 
-    @pytest.mark.django_db(transaction=True, reset_sequences=True)
+    @pytest.mark.django_db(reset_sequences=True)
     def test_reset_sequences_enabled(self, request) -> None:
         marker = request.node.get_closest_marker("django_db")
         assert marker.kwargs["reset_sequences"]
 
+    @pytest.mark.django_db(transaction=True, reset_sequences=True)
+    def test_transaction_reset_sequences_enabled(self, request) -> None:
+        marker = request.node.get_closest_marker("django_db")
+        assert marker.kwargs["reset_sequences"]
+
     @pytest.mark.django_db(databases=['default', 'replica', 'second'])
     def test_databases(self, request) -> None:
         marker = request.node.get_closest_marker("django_db")
Repository: rigetti/pyquil (python)

Issue:
`ADD-KRAUS` does not pass the gate name to `Pragma` constructor
As is `ADD-KRAUS` is broken, but the fix is easy.


Discussion:

Patch:
diff --git a/pyquil/kraus.py b/pyquil/kraus.py
--- a/pyquil/kraus.py
+++ b/pyquil/kraus.py
@@ -50,9 +50,8 @@ def _create_kraus_pragmas(name, qubit_indices, kraus_ops):
     :rtype: str
     """
 
-    prefix = "PRAGMA ADD-KRAUS {} {}".format(name, " ".join(map(str, qubit_indices)))
     pragmas = [Pragma("ADD-KRAUS",
-                      qubit_indices,
+                      [name] + list(qubit_indices),
                       "({})".format(" ".join(map(format_parameter, np.ravel(k)))))
                for k in kraus_ops]
     return pragmas


Test patch:
diff --git a/pyquil/tests/test_quil.py b/pyquil/tests/test_quil.py
--- a/pyquil/tests/test_quil.py
+++ b/pyquil/tests/test_quil.py
@@ -520,11 +520,11 @@ def test_kraus():
 
     ret = pq.out()
     assert ret == """X 0
-PRAGMA ADD-KRAUS 0 "(0.0+0.0i 1.0+0.0i 1.0+0.0i 0.0+0.0i)"
-PRAGMA ADD-KRAUS 0 "(0.0+0.0i 0.0+0.0i 0.0+0.0i 0.0+0.0i)"
+PRAGMA ADD-KRAUS X 0 "(0.0+0.0i 1.0+0.0i 1.0+0.0i 0.0+0.0i)"
+PRAGMA ADD-KRAUS X 0 "(0.0+0.0i 0.0+0.0i 0.0+0.0i 0.0+0.0i)"
 X 1
-PRAGMA ADD-KRAUS 1 "(0.0+0.0i 1.0+0.0i 1.0+0.0i 0.0+0.0i)"
-PRAGMA ADD-KRAUS 1 "(0.0+0.0i 0.0+0.0i 0.0+0.0i 0.0+0.0i)"
+PRAGMA ADD-KRAUS X 1 "(0.0+0.0i 1.0+0.0i 1.0+0.0i 0.0+0.0i)"
+PRAGMA ADD-KRAUS X 1 "(0.0+0.0i 0.0+0.0i 0.0+0.0i 0.0+0.0i)"
 """
     # test error due to bad normalization
     with pytest.raises(ValueError):
Repository: pytest-dev/pytest-django (python)

Issue:
django.test.TestCase with multiples database doesn't create secondary db in 4.11.0

With the 4.11.0 version, if a Django TestCase is setup to use multiples database with the `databases` attribute, only the default database is created on runtime.

```
class Test(TestCase):
    databases = {"default", "db2"}
```

Trying to add the decorator `@pytest.mark.django_db(databases=['default', 'db2'])`  on the class doesn't work either.

The problem seems to come from the line [133 in pytest_django/fixtures.py](https://github.com/pytest-dev/pytest-django/blob/6d5c272519037031f0b68d78dca44727b860d65e/pytest_django/fixtures.py#L133)

The line tries to get an attribute from the test function and not from the test class.

```
        databases = getattr(test_cls, "databases", None)
```
This fixes the problem with Django TestCase without altering pytest.mark.django_db


PS : the line 132 (serialized_rollback) seems to be broken also. I have not tried using _serialized_rollback_, so I can't confirm.


Discussion:
Ouch, silly mistake! I will fix and do a patch release. Thanks for the report.

Patch:
diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py
--- a/pytest_django/fixtures.py
+++ b/pytest_django/fixtures.py
@@ -129,8 +129,8 @@ def _get_databases_for_test(test: pytest.Item) -> tuple[Iterable[str], bool]:
 
     test_cls = getattr(test, "cls", None)
     if test_cls and issubclass(test_cls, TransactionTestCase):
-        serialized_rollback = getattr(test, "serialized_rollback", False)
-        databases = getattr(test, "databases", None)
+        serialized_rollback = getattr(test_cls, "serialized_rollback", False)
+        databases = getattr(test_cls, "databases", None)
     else:
         fixtures = getattr(test, "fixturenames", ())
         marker_db = test.get_closest_marker("django_db")


Test patch:
diff --git a/tests/test_database.py b/tests/test_database.py
--- a/tests/test_database.py
+++ b/tests/test_database.py
@@ -432,6 +432,28 @@ def test_db_access_3(self):
     )
 
 
+def test_django_testcase_multi_db(django_pytester: DjangoPytester) -> None:
+    """Test that Django TestCase multi-db support works."""
+
+    django_pytester.create_test_module(
+        """
+        import pytest
+        from django.test import TestCase
+        from .app.models import Item, SecondItem
+
+        class TestCase(TestCase):
+            databases = ["default", "second"]
+
+            def test_db_access(self):
+                Item.objects.count() == 0
+                SecondItem.objects.count() == 0
+        """
+    )
+
+    result = django_pytester.runpytest_subprocess("-v", "--reuse-db")
+    result.assert_outcomes(passed=1)
+
+
 class Test_database_blocking:
     def test_db_access_in_conftest(self, django_pytester: DjangoPytester) -> None:
         """Make sure database access in conftest module is prohibited."""
Repository: rigetti/pyquil (python)

Issue:
T2 noise model is wrong when T1 is finite
In particular, a damping noise model with T1 will lead to a contribution to the dephasing rate 1/T2 that equals 1/(2*T1).


Discussion:

Patch:
diff --git a/pyquil/noise.py b/pyquil/noise.py
--- a/pyquil/noise.py
+++ b/pyquil/noise.py
@@ -324,10 +324,24 @@ def damping_after_dephasing(T1, T2, gate_time):
     :param float gate_time: The gate duration.
     :return: A list of Kraus operators.
     """
-    damping = damping_kraus_map(p=1 - np.exp(-float(gate_time) / float(T1))) \
-        if T1 != INFINITY else [np.eye(2)]
-    dephasing = dephasing_kraus_map(p=.5 * (1 - np.exp(-2 * gate_time / float(T2)))) \
-        if T2 != INFINITY else [np.eye(2)]
+    assert T1 >= 0
+    assert T2 >= 0
+
+    if T1 != INFINITY:
+        damping = damping_kraus_map(p=1 - np.exp(-float(gate_time) / float(T1)))
+    else:
+        damping = [np.eye(2)]
+
+    if T2 != INFINITY:
+        gamma_phi = float(gate_time) / float(T2)
+        if T1 != INFINITY:
+            if T2 > 2 * T1:
+                raise ValueError("T2 is upper bounded by 2 * T1")
+            gamma_phi -= float(gate_time) / float(2 * T1)
+
+        dephasing = dephasing_kraus_map(p=.5 * (1 - np.exp(-2 * gamma_phi)))
+    else:
+        dephasing = [np.eye(2)]
     return combine_kraus_maps(damping, dephasing)
 
 


Test patch:
diff --git a/pyquil/tests/test_noise.py b/pyquil/tests/test_noise.py
--- a/pyquil/tests/test_noise.py
+++ b/pyquil/tests/test_noise.py
@@ -70,7 +70,7 @@ def test_damping_after_dephasing():
     dephasing = dephasing_kraus_map(p=.5 * (1 - np.exp(-.2)))
     ks_ref = combine_kraus_maps(damping, dephasing)
 
-    ks_actual = damping_after_dephasing(10, 10, 1)
+    ks_actual = damping_after_dephasing(20, 40 / 3., 2.)
     np.testing.assert_allclose(ks_actual, ks_ref)
Repository: pytest-dev/pytest-django (python)

Issue:
admin_client is not checking for login success
`client.login` inside `admin_client` can return `False` in the case when there's an existing admin user with a password set to something other than `'password'`. Perhaps, `admin_client` should use `force_login` instead?


Discussion:
Seems sensible
Can you provide a failing test and fix in a PR?
Sure, I'll do that in the next couple of days.

Patch:
diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py
--- a/pytest_django/fixtures.py
+++ b/pytest_django/fixtures.py
@@ -304,7 +304,7 @@ def admin_client(db, admin_user):
     from django.test.client import Client
 
     client = Client()
-    client.login(username=admin_user.username, password="password")
+    client.force_login(admin_user)
     return client
 
 


Test patch:
diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py
--- a/tests/test_fixtures.py
+++ b/tests/test_fixtures.py
@@ -49,6 +49,17 @@ def test_admin_client_no_db_marker(admin_client):
     assert force_str(resp.content) == "You are an admin"
 
 
+# For test below.
+@pytest.fixture
+def existing_admin_user(django_user_model):
+    return django_user_model._default_manager.create_superuser('admin', None, None)
+
+
+def test_admin_client_existing_user(db, existing_admin_user, admin_user, admin_client):
+    resp = admin_client.get("/admin-required/")
+    assert force_str(resp.content) == "You are an admin"
+
+
 @pytest.mark.django_db
 def test_admin_user(admin_user, django_user_model):
     assert isinstance(admin_user, django_user_model)
Repository: pytest-dev/pytest-django (python)

Issue:
Handle transaction.atomic(durable=True)
This argument will be introduced in Django 3.2: https://docs.djangoproject.com/en/3.2/topics/db/transactions/#controlling-transactions-explicitly

It's used to make sure that atomic blocks aren't nested and naturally this fails when running the test suite. The django `TestCase`-class handles this by setting `transaction.Atomic._ensure_durability = False` in `setUpClass` and setting it back to `True` on `tearDownClass`.

I'm not that familiar with the codebase but I wonder if it would make sense to adjust the non-transactional block in `_django_db_fixture_helper` with something like:
```python
transaction.Atomic._ensure_durability = False
def reset_durability():
    transaction.Atomic._ensure_durability = True
request.addfinalizer(reset_durability)
```


Discussion:

Patch:
diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py
--- a/pytest_django/fixtures.py
+++ b/pytest_django/fixtures.py
@@ -147,6 +147,12 @@ class ResetSequenceTestCase(django_case):
             django_case = ResetSequenceTestCase
     else:
         from django.test import TestCase as django_case
+        from django.db import transaction
+        transaction.Atomic._ensure_durability = False
+
+        def reset_durability():
+            transaction.Atomic._ensure_durability = True
+        request.addfinalizer(reset_durability)
 
     test_case = django_case(methodName="__init__")
     test_case._pre_setup()


Test patch:
diff --git a/tests/test_database.py b/tests/test_database.py
--- a/tests/test_database.py
+++ b/tests/test_database.py
@@ -1,7 +1,8 @@
 import pytest
-from django.db import connection
+from django.db import connection, transaction
 from django.test.testcases import connections_support_transactions
 
+from pytest_django.lazy_django import get_django_version
 from pytest_django_test.app.models import Item
 
 
@@ -138,6 +139,12 @@ def test_fin(self, fin):
         # Check finalizer has db access (teardown will fail if not)
         pass
 
+    @pytest.mark.skipif(get_django_version() < (3, 2), reason="Django >= 3.2 required")
+    def test_durable_transactions(self, all_dbs):
+        with transaction.atomic(durable=True):
+            item = Item.objects.create(name="foo")
+        assert Item.objects.get() == item
+
 
 class TestDatabaseFixturesAllOrder:
     @pytest.fixture
Repository: rigetti/pyquil (python)

Issue:
Creating a gate with all integers throws an error
```python
>>> DefGate("A", np.array([[1, 0], [0, 1]])).out()
```

throws the following error:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/steven/workspace/pyquil/pyquil/quilbase.py", line 208, in out
    fcols = [format_matrix_element(col) for col in row]
  File "/Users/steven/workspace/pyquil/pyquil/quilbase.py", line 208, in <listcomp>
    fcols = [format_matrix_element(col) for col in row]
  File "/Users/steven/workspace/pyquil/pyquil/quilbase.py", line 68, in format_matrix_element
    assert False, "Invalid matrix element: %r" % element
AssertionError: Invalid matrix element: 1
```

The type of the integer in a numpy array of all ints is unexpected:
```python
>>> type(np.array([[1, 0], [0, 1]])[0][0])
<class 'numpy.int64'>
```


Discussion:
That is strange, it works for me.

![screen shot 2017-10-09 at 7 05 08 pm](https://user-images.githubusercontent.com/21032071/31340931-6a86d834-ad25-11e7-8bf3-8b46aee3676a.png)

What's the different numpy versions?
Mine is 1.13.3
Might be a Python version thing. I'm on Python 3, numpy 1.13.3
I'm also affected by this. numpy 1.13.0, python 3.6.1 .

Patch:
diff --git a/pyquil/quilbase.py b/pyquil/quilbase.py
--- a/pyquil/quilbase.py
+++ b/pyquil/quilbase.py
@@ -261,7 +261,7 @@ def format_matrix_element(element):
 
             :param element: {int, float, complex, str} The parameterized element to format.
             """
-            if isinstance(element, integer_types) or isinstance(element, (float, complex)):
+            if isinstance(element, integer_types) or isinstance(element, (float, complex, np.int_)):
                 return format_parameter(element)
             elif isinstance(element, string_types):
                 return element
@@ -514,7 +514,7 @@ def format_parameter(element):
 
     :param element: {int, float, long, complex, Slot} Formats a parameter for Quil output.
     """
-    if isinstance(element, integer_types):
+    if isinstance(element, integer_types) or isinstance(element, np.int_):
         return repr(element)
     elif isinstance(element, float):
         return check_for_pi(element)


Test patch:
diff --git a/pyquil/tests/test_quil.py b/pyquil/tests/test_quil.py
--- a/pyquil/tests/test_quil.py
+++ b/pyquil/tests/test_quil.py
@@ -582,3 +582,10 @@ def test_pretty_print_pi():
     assert p.out() == 'RZ(0) 0\nRZ(pi) 1\nRZ(-pi) 2\nRZ(2*pi/3) 3\n' \
                       'RZ(0.3490658503988659) 4\n' \
                       'RZ(pi/8) 5\nCPHASE00(-45*pi) 0 1\n'
+
+
+# https://github.com/rigetticomputing/pyquil/issues/138
+def test_defgate_integer_input():
+    dg = DefGate("TEST", np.array([[1, 0],
+                                   [0, 1]]))
+    assert dg.out() == "DEFGATE TEST:\n    1, 0\n    0, 1\n"
Repository: nginx/njs (c)

Issue:
EarleyBoyer: RangeError: Maximum call stack size exceeded
### Describe the bug

v8-v7 EarleyBoyer test run fails

[run.zip](https://github.com/user-attachments/files/21028584/run.zip)

### To reproduce

- JS script
```js
function f(n) {
  console.log(n)
  f(n + 1)
}

f(0)
``` 


### Expected behavior
njs sets a stack size of 64kb by default, which seems to be the smallest


For the above test code, the maximum stack of other engines:
```
mujs 1020
qjs 598
njs 229
```

 
### Your environment

- Version of njs or specific commit: master
- OS: [e.g. Ubuntu 24.04]

### Additional context

Although it is possible to set a larger stack size through the command line, for modern complex applications, is it possible to set a larger default stack size for ease of use?


Discussion:

Patch:
diff --git a/src/njs_vm.h b/src/njs_vm.h
--- a/src/njs_vm.h
+++ b/src/njs_vm.h
@@ -8,7 +8,7 @@
 #define _NJS_VM_H_INCLUDED_
 
 
-#define NJS_MAX_STACK_SIZE       (64 * 1024)
+#define NJS_MAX_STACK_SIZE       (160 * 1024)
 
 
 typedef struct njs_frame_s            njs_frame_t;


Test patch:
diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c
+++ b/src/test/njs_unit_test.c
@@ -21856,6 +21856,7 @@ njs_unit_test(njs_unit_test_t tests[], size_t num, njs_str_t *name,
         options.module = opts->module;
         options.unsafe = opts->unsafe;
         options.backtrace = opts->backtrace;
+        options.max_stack_size = 64 * 1024;
         options.addons = opts->externals ? njs_unit_test_addon_external_modules
                                          : njs_unit_test_addon_modules;
 
@@ -22008,6 +22009,7 @@ njs_interactive_test(njs_unit_test_t tests[], size_t num, njs_str_t *name,
         options.init = 1;
         options.interactive = 1;
         options.backtrace = 1;
+        options.max_stack_size = 64 * 1024;
         options.addons = opts->externals ? njs_unit_test_addon_external_modules
                                          : njs_unit_test_addon_modules;
Repository: nginx/njs (c)

Issue:
memmove-vec-unaligned-erms
Testcase

```js
delete this.global 
```

ASAN

```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==82143==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fee4e4e813f bp 0x7ffe41ff2930 sp 0x7ffe41ff20b8 T0)
==82143==The signal is caused by a WRITE memory access.
==82143==Hint: address points to the zero page.
    #0 0x7fee4e4e813e in memcpy /build/glibc-uZu3wS/glibc-2.27/string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:144
    #1 0x4d9d0d in __asan_memcpy (/home/xxx/Desktop/njs/build/njs+0x4d9d0d)
    #2 0x896f69 in njs_global_this_object /home/xxx/Desktop/njs/src/njs_builtin.c:786:5
    #3 0x5542f2 in njs_value_property_delete /home/xxx/Desktop/njs/src/njs_value.c:1490:19
    #4 0x594845 in njs_vmcode_interpreter /home/xxx/Desktop/njs/src/njs_vmcode.c:924:15
    #5 0x5610fb in njs_vm_start /home/xxx/Desktop/njs/src/njs_vm.c:664:11
    #6 0x51d7fd in njs_engine_njs_eval /home/xxx/Desktop/njs/external/njs_shell.c:1387:16
    #7 0x519147 in njs_process_script /home/xxx/Desktop/njs/external/njs_shell.c:3528:11
    #8 0x519147 in njs_process_file /home/xxx/Desktop/njs/external/njs_shell.c:3500
    #9 0x519147 in njs_main /home/xxx/Desktop/njs/external/njs_shell.c:458
    #10 0x519147 in main /home/xxx/Desktop/njs/external/njs_shell.c:488
    #11 0x7fee4e44ec86 in __libc_start_main /build/glibc-uZu3wS/glibc-2.27/csu/../csu/libc-start.c:310
    #12 0x41b3e9 in _start (/home/xxx/Desktop/njs/build/njs+0x41b3e9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /build/glibc-uZu3wS/glibc-2.27/string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:144 in memcpy
==82143==ABORTING

```


Discussion:

Patch:
diff --git a/src/njs_builtin.c b/src/njs_builtin.c
--- a/src/njs_builtin.c
+++ b/src/njs_builtin.c
@@ -783,13 +783,14 @@ njs_global_this_object(njs_vm_t *vm, njs_object_prop_t *self,
     njs_object_prop_t   *prop;
     njs_lvlhsh_query_t  lhq;
 
+    if (retval == NULL) {
+        return NJS_DECLINED;
+    }
+
     njs_value_assign(retval, global);
 
     if (njs_slow_path(setval != NULL)) {
         njs_value_assign(retval, setval);
-
-    } else if (njs_slow_path(retval == NULL)) {
-        return NJS_DECLINED;
     }
 
     prop = njs_object_prop_alloc(vm, &self->name, retval, 1);


Test patch:
diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c
+++ b/src/test/njs_unit_test.c
@@ -12885,6 +12885,9 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("var ex; try {({}) instanceof this} catch (e) {ex = e}; ex"),
       njs_str("TypeError: right argument is not callable") },
 
+    { njs_str("delete global.global; global"),
+      njs_str("ReferenceError: \"global\" is not defined") },
+
     { njs_str("njs"),
       njs_str("[object njs]") },