Skip to content

Commit

Permalink
set_global returns name of variable instead True
Browse files Browse the repository at this point in the history
  • Loading branch information
813gan committed Aug 15, 2024
1 parent 25f5af2 commit ee024f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion subinterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ PyObject *set_global(char *interpreter_name, PyObject *obj, PyObject *as) {
SUBINTERPRETER_SWITCH;
PyObject_SetItem(global_dict, as, obj);
PyObject *exception = PyErr_GetRaisedException();
PyObject *ret = Py_True;
PyObject *ret = Py_NewRef(as);

SUBINTERPRETER_RETURN;
}
14 changes: 7 additions & 7 deletions tests/test.el
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
:type 'python-exception) )

(ert-deftest ert-test-emacspy-py-set-global ()
(should (py-set-global "test" "test_value" "test_str"))
(should (string= "test_str" (py-set-global "test" "test_value" "test_str")))
(should (string= "test_value" (py-get-global-variable "test" "test_str"))) )

(ert-deftest ert-test-emacspy-import-custom-module ()
Expand All @@ -64,9 +64,9 @@
(load "emacspy"))))

(ert-deftest ert-test-emacspy-data-int ()
(should (py-set-global "test" 1 "test_int"))
(should (eq 1 (py-get-global-variable "test" "test_int")))
(should (py-set-global "test" -1 "test_int"))
(should (eq -1 (py-get-global-variable "test" "test_int")))
(should (py-set-global "test" 0 "test_int"))
(should (eq 0 (py-get-global-variable "test" "test_int"))) )
(should (eq 1 (py-get-global-variable
"test" (py-set-global "test" 1 "test_int"))))
(should (eq -1 (py-get-global-variable
"test" (py-set-global "test" -1 "test_int"))))
(should (eq 0 (py-get-global-variable
"test" (py-set-global "test" 0 "test_int")))) )

0 comments on commit ee024f1

Please sign in to comment.