~ubuntu-branches/ubuntu/wily/sip4/wily-proposed

« back to all changes in this revision

Viewing changes to siplib/siplib.c.in

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Dmitry Shachnev, Scott Kitterman
  • Date: 2015-07-19 12:17:06 UTC
  • mfrom: (1.5.5)
  • Revision ID: package-import@ubuntu.com-20150719121706-9optmryjgk7scu7k
Tags: 4.16.9+dfsg-1
[ Dmitry Shachnev ]
* More minor simplifications to sipconfig wrappers.

[ Scott Kitterman ]
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
7454
7454
 
7455
7455
 
7456
7456
/*
7457
 
 * Report a Python member function with an unexpected return type.
 
7457
 * Report a Python member function with an unexpected result.
7458
7458
 */
7459
7459
static void sip_api_bad_catcher_result(PyObject *method)
7460
7460
{
7461
 
    PyObject *mname;
 
7461
    PyObject *mname, *etype, *evalue, *etraceback;
 
7462
 
 
7463
    /*
 
7464
     * Get the current exception object if there is one.  Its string
 
7465
     * representation will be used as the detail of a new exception.
 
7466
     */
 
7467
    PyErr_Fetch(&etype, &evalue, &etraceback);
 
7468
    PyErr_NormalizeException(&etype, &evalue, &etraceback);
 
7469
    Py_XDECREF(etype);
 
7470
    Py_XDECREF(etraceback);
7462
7471
 
7463
7472
    /*
7464
7473
     * This is part of the public API so we make no assumptions about the
7476
7485
 
7477
7486
    mname = ((PyFunctionObject *)PyMethod_GET_FUNCTION(method))->func_name;
7478
7487
 
7479
 
#if PY_MAJOR_VERSION >= 3
7480
 
    PyErr_Format(PyExc_TypeError, "invalid result type from %s.%U()",
7481
 
            Py_TYPE(PyMethod_GET_SELF(method))->tp_name, mname);
7482
 
#else
7483
 
    PyErr_Format(PyExc_TypeError, "invalid result type from %s.%s()",
7484
 
            Py_TYPE(PyMethod_GET_SELF(method))->tp_name,
7485
 
            PyString_AsString(mname));
7486
 
#endif
 
7488
    if (evalue != NULL)
 
7489
    {
 
7490
#if PY_MAJOR_VERSION >= 3
 
7491
        PyErr_Format(PyExc_TypeError, "invalid result from %s.%U(), %S",
 
7492
                Py_TYPE(PyMethod_GET_SELF(method))->tp_name, mname, evalue);
 
7493
#else
 
7494
        PyObject *evalue_s = PyObject_Str(evalue);
 
7495
 
 
7496
        PyErr_Format(PyExc_TypeError, "invalid result from %s.%s(), %s",
 
7497
                Py_TYPE(PyMethod_GET_SELF(method))->tp_name,
 
7498
                PyString_AsString(mname), PyString_AsString(evalue_s));
 
7499
 
 
7500
        Py_XDECREF(evalue_s);
 
7501
#endif
 
7502
 
 
7503
        Py_DECREF(evalue);
 
7504
    }
 
7505
    else
 
7506
    {
 
7507
#if PY_MAJOR_VERSION >= 3
 
7508
        PyErr_Format(PyExc_TypeError, "invalid result from %s.%U()",
 
7509
                Py_TYPE(PyMethod_GET_SELF(method))->tp_name, mname);
 
7510
#else
 
7511
        PyErr_Format(PyExc_TypeError, "invalid result from %s.%s()",
 
7512
                Py_TYPE(PyMethod_GET_SELF(method))->tp_name,
 
7513
                PyString_AsString(mname));
 
7514
#endif
 
7515
    }
7487
7516
}
7488
7517
 
7489
7518
 
8517
8546
{
8518
8547
    int ok;
8519
8548
 
8520
 
    assert(sipTypeIsClass(td) || sipTypeIsMapped(td));
 
8549
    assert(td == NULL || sipTypeIsClass(td) || sipTypeIsMapped(td));
8521
8550
 
8522
 
    /* None is handled outside the type checkers. */
8523
 
    if (pyObj == Py_None)
 
8551
    if (td == NULL)
 
8552
    {
 
8553
        /*
 
8554
         * The type must be /External/ and the module that contains the
 
8555
         * implementation hasn't been imported.
 
8556
         */
 
8557
        ok = FALSE;
 
8558
    }
 
8559
    else if (pyObj == Py_None)
8524
8560
    {
8525
8561
        /* If the type explicitly handles None then ignore the flags. */
8526
8562
        if (sipTypeAllowNone(td))
10623
10659
    vret = sipSimpleWrapper_clear(sw);
10624
10660
 
10625
10661
    /* Remove any slots connected via a proxy. */
10626
 
    if (sipQtSupport != NULL && sipPossibleProxy(sw))
 
10662
    if (sipQtSupport != NULL && sipPossibleProxy(sw) && !sipNotInMap(sw))
10627
10663
    {
10628
10664
        void *tx = sip_api_get_address(sw);
10629
10665
 
10682
10718
    if ((vret = sipSimpleWrapper_traverse(sw, visit, arg)) != 0)
10683
10719
        return vret;
10684
10720
 
10685
 
    /* This should be handwritten code in PyQt. */
10686
 
    if (sipQtSupport != NULL && sipQtSupport->qt_find_sipslot)
 
10721
    /*
 
10722
     * This should be handwritten code in PyQt.  The map check is a bit of a
 
10723
     * hack to work around PyQt4 problems with qApp and a user created
 
10724
     * instance.  qt_find_sipslot() will return the same slot information for
 
10725
     * both causing the gc module to trigger assert() failures.
 
10726
     */
 
10727
    if (sipQtSupport != NULL && sipQtSupport->qt_find_sipslot && !sipNotInMap(sw))
10687
10728
    {
10688
10729
        void *tx = sip_api_get_address(sw);
10689
10730
 
12284
12325
     */
12285
12326
    sipResetPyOwned(sw);
12286
12327
 
 
12328
    sipOMRemoveObject(&cppPyMap, sw);
 
12329
 
12287
12330
    clear_access_func(sw);
12288
12331
}