~ubuntu-branches/ubuntu/wily/weechat/wily

« back to all changes in this revision

Viewing changes to src/plugins/python/weechat-python.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2014-09-28 17:41:10 UTC
  • mfrom: (29.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140928174110-bwlsn7gqmqfftnmb
Tags: 1.0.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
391
391
            ret_value = NULL;
392
392
        Py_XDECREF(rc);
393
393
    }
394
 
    else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (PyLong_Check (rc)))
 
394
    else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (PY_INTEGER_CHECK(rc)))
395
395
    {
396
396
        ret_int = malloc (sizeof (*ret_int));
397
397
        if (ret_int)
398
 
            *ret_int = (int) PyLong_AsLong(rc);
 
398
            *ret_int = (int) PyLong_AsLong (rc);
399
399
        ret_value = ret_int;
400
400
        Py_XDECREF(rc);
401
401
    }
766
766
                                        &weechat_python_api_buffer_input_data_cb,
767
767
                                        &weechat_python_api_buffer_close_cb);
768
768
 
769
 
    weechat_hook_signal_send ("python_script_loaded", WEECHAT_HOOK_SIGNAL_STRING,
770
 
                              python_current_script->filename);
 
769
    (void) weechat_hook_signal_send ("python_script_loaded",
 
770
                                     WEECHAT_HOOK_SIGNAL_STRING,
 
771
                                     python_current_script->filename);
771
772
 
772
773
    return 1;
773
774
}
794
795
{
795
796
    int *rc;
796
797
    void *interpreter;
797
 
    PyThreadState *old_interpreter;
798
798
    char *filename;
799
799
 
800
800
    if ((weechat_python_plugin->debug >= 2) || !python_quiet)
813
813
    }
814
814
 
815
815
    filename = strdup (script->filename);
816
 
    old_interpreter = PyThreadState_Swap (NULL);
817
816
    interpreter = script->interpreter;
818
817
 
819
818
    if (python_current_script == script)
 
819
    {
820
820
        python_current_script = (python_current_script->prev_script) ?
821
821
            python_current_script->prev_script : python_current_script->next_script;
 
822
    }
822
823
 
823
824
    plugin_script_remove (weechat_python_plugin, &python_scripts, &last_python_script,
824
825
                          script);
829
830
        Py_EndInterpreter (interpreter);
830
831
    }
831
832
 
832
 
    if (old_interpreter)
833
 
        PyThreadState_Swap (old_interpreter);
 
833
    if (python_current_script)
 
834
        PyThreadState_Swap (python_current_script->interpreter);
834
835
 
835
 
    weechat_hook_signal_send ("python_script_unloaded",
836
 
                              WEECHAT_HOOK_SIGNAL_STRING, filename);
 
836
    (void) weechat_hook_signal_send ("python_script_unloaded",
 
837
                                     WEECHAT_HOOK_SIGNAL_STRING, filename);
837
838
    if (filename)
838
839
        free (filename);
839
840
}
958
959
        {
959
960
            weechat_python_unload_all ();
960
961
        }
 
962
        else
 
963
            return WEECHAT_RC_ERROR;
961
964
    }
962
965
    else
963
966
    {
1007
1010
            python_quiet = 0;
1008
1011
        }
1009
1012
        else
1010
 
        {
1011
 
            weechat_printf (NULL,
1012
 
                            weechat_gettext ("%s%s: unknown option for "
1013
 
                                             "command \"%s\""),
1014
 
                            weechat_prefix ("error"), PYTHON_PLUGIN_NAME,
1015
 
                            "python");
1016
 
        }
 
1013
            return WEECHAT_RC_ERROR;
1017
1014
    }
1018
1015
 
1019
1016
    return WEECHAT_RC_OK;