Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 180039
Collapse All | Expand All

(-)pypcap-1.1/pcap.c.orig (-123 / +103 lines)
Lines 1-45 Link Here
1
/* Generated by Pyrex 0.9.3 on Sun Oct 16 19:38:39 2005 */
1
/* Generated by Pyrex 0.9.5.1a on Mon May 28 20:38:29 2007 */
2
2
3
#include "Python.h"
3
#include "Python.h"
4
#include "structmember.h"
4
#include "structmember.h"
5
#ifndef PY_LONG_LONG
5
#ifndef PY_LONG_LONG
6
  #define PY_LONG_LONG LONG_LONG
6
  #define PY_LONG_LONG LONG_LONG
7
#endif
7
#endif
8
#ifdef __cplusplus
9
#define __PYX_EXTERN_C extern "C"
10
#else
11
#define __PYX_EXTERN_C extern
12
#endif
13
__PYX_EXTERN_C double pow(double, double);
8
#include "pcap.h"
14
#include "pcap.h"
9
#include "pcap_ex.h"
15
#include "pcap_ex.h"
10
16
11
17
12
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
18
typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
13
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
19
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
14
static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/
15
static int __Pyx_EndUnpack(PyObject *, int); /*proto*/
16
static int __Pyx_PrintItem(PyObject *); /*proto*/
17
static int __Pyx_PrintNewline(void); /*proto*/
18
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
19
static void __Pyx_ReRaise(void); /*proto*/
20
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
21
static PyObject *__Pyx_GetExcValue(void); /*proto*/
22
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/
23
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
24
static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/
25
static void __Pyx_WriteUnraisable(char *name); /*proto*/
26
static void __Pyx_AddTraceback(char *funcname); /*proto*/
27
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/
28
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
29
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
30
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
31
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
32
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
33
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
34
20
35
static PyObject *__pyx_m;
21
static PyObject *__pyx_m;
36
static PyObject *__pyx_b;
22
static PyObject *__pyx_b;
37
static int __pyx_lineno;
23
static int __pyx_lineno;
38
static char *__pyx_filename;
24
static char *__pyx_filename;
39
staticforward char **__pyx_f;
25
static char **__pyx_f;
40
26
41
static char __pyx_mdoc[] = "packet capture library\n\nThis module provides a high level interface to packet capture systems.\nAll packets on the network, even those destined for other hosts, are\naccessible through this mechanism.\n";
27
static char __pyx_mdoc[] = "packet capture library\n\nThis module provides a high level interface to packet capture systems.\nAll packets on the network, even those destined for other hosts, are\naccessible through this mechanism.\n";
42
28
29
static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/
30
31
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
32
33
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
34
35
static PyObject *__Pyx_GetExcValue(void); /*proto*/
36
37
static void __Pyx_WriteUnraisable(char *name); /*proto*/
38
39
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
40
41
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
42
43
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44
45
static void __Pyx_AddTraceback(char *funcname); /*proto*/
46
43
/* Declarations from pcap */
47
/* Declarations from pcap */
44
48
45
struct __pyx_t_4pcap_pcap_handler_ctx {
49
struct __pyx_t_4pcap_pcap_handler_ctx {
Lines 48-61 Link Here
48
  int got_exc;
52
  int got_exc;
49
};
53
};
50
54
51
staticforward PyTypeObject __pyx_type_4pcap_bpf;
52
55
53
struct __pyx_obj_4pcap_bpf {
56
struct __pyx_obj_4pcap_bpf {
54
  PyObject_HEAD
57
  PyObject_HEAD
55
  struct bpf_program fcode;
58
  struct bpf_program fcode;
56
};
59
};
57
60
58
staticforward PyTypeObject __pyx_type_4pcap_pcap;
59
61
60
struct __pyx_obj_4pcap_pcap {
62
struct __pyx_obj_4pcap_pcap {
61
  PyObject_HEAD
63
  PyObject_HEAD
Lines 78-83 Link Here
78
static PyObject *__pyx_k20;
80
static PyObject *__pyx_k20;
79
static void (__pyx_f_4pcap___pcap_handler(void (*),struct pcap_pkthdr (*),char (*))); /*proto*/
81
static void (__pyx_f_4pcap___pcap_handler(void (*),struct pcap_pkthdr (*),char (*))); /*proto*/
80
82
83
81
/* Implementation of pcap */
84
/* Implementation of pcap */
82
85
83
static char (__pyx_k1[]) = "Network interface or dumpfile name.";
86
static char (__pyx_k1[]) = "Network interface or dumpfile name.";
Lines 295-301 Link Here
295
  __pyx_2 = 0;
298
  __pyx_2 = 0;
296
  goto __pyx_L0;
299
  goto __pyx_L0;
297
300
298
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
301
  __pyx_r = Py_None; Py_INCREF(Py_None);
299
  goto __pyx_L0;
302
  goto __pyx_L0;
300
  __pyx_L1:;
303
  __pyx_L1:;
301
  Py_XDECREF(__pyx_1);
304
  Py_XDECREF(__pyx_1);
Lines 316-325 Link Here
316
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":143 */
319
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":143 */
317
  pcap_freecode((&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode));
320
  pcap_freecode((&((struct __pyx_obj_4pcap_bpf *)__pyx_v_self)->fcode));
318
321
319
  goto __pyx_L0;
320
  __pyx_L1:;
321
  __Pyx_AddTraceback("pcap.bpf.__dealloc__");
322
  __pyx_L0:;
323
  Py_DECREF(__pyx_v_self);
322
  Py_DECREF(__pyx_v_self);
324
}
323
}
325
324
Lines 370-376 Link Here
370
    __pyx_v_p = pcap_ex_lookupdev(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
369
    __pyx_v_p = pcap_ex_lookupdev(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
371
370
372
    /* "/Users/dugsong/projects/pypcap/pcap.pyx":170 */
371
    /* "/Users/dugsong/projects/pypcap/pcap.pyx":170 */
373
    __pyx_1 = (__pyx_v_p == 0);
372
    __pyx_1 = (__pyx_v_p == NULL);
374
    if (__pyx_1) {
373
    if (__pyx_1) {
375
374
376
      /* "/Users/dugsong/projects/pypcap/pcap.pyx":171 */
375
      /* "/Users/dugsong/projects/pypcap/pcap.pyx":171 */
Lines 511-517 Link Here
511
  __pyx_1 = 0;
510
  __pyx_1 = 0;
512
  goto __pyx_L0;
511
  goto __pyx_L0;
513
512
514
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
513
  __pyx_r = Py_None; Py_INCREF(Py_None);
515
  goto __pyx_L0;
514
  goto __pyx_L0;
516
  __pyx_L1:;
515
  __pyx_L1:;
517
  Py_XDECREF(__pyx_1);
516
  Py_XDECREF(__pyx_1);
Lines 534-540 Link Here
534
  __pyx_1 = 0;
533
  __pyx_1 = 0;
535
  goto __pyx_L0;
534
  goto __pyx_L0;
536
535
537
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
536
  __pyx_r = Py_None; Py_INCREF(Py_None);
538
  goto __pyx_L0;
537
  goto __pyx_L0;
539
  __pyx_L1:;
538
  __pyx_L1:;
540
  Py_XDECREF(__pyx_1);
539
  Py_XDECREF(__pyx_1);
Lines 557-563 Link Here
557
  __pyx_1 = 0;
556
  __pyx_1 = 0;
558
  goto __pyx_L0;
557
  goto __pyx_L0;
559
558
560
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
559
  __pyx_r = Py_None; Py_INCREF(Py_None);
561
  goto __pyx_L0;
560
  goto __pyx_L0;
562
  __pyx_L1:;
561
  __pyx_L1:;
563
  Py_XDECREF(__pyx_1);
562
  Py_XDECREF(__pyx_1);
Lines 580-586 Link Here
580
  __pyx_1 = 0;
579
  __pyx_1 = 0;
581
  goto __pyx_L0;
580
  goto __pyx_L0;
582
581
583
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
582
  __pyx_r = Py_None; Py_INCREF(Py_None);
584
  goto __pyx_L0;
583
  goto __pyx_L0;
585
  __pyx_L1:;
584
  __pyx_L1:;
586
  Py_XDECREF(__pyx_1);
585
  Py_XDECREF(__pyx_1);
Lines 603-609 Link Here
603
  __pyx_1 = 0;
602
  __pyx_1 = 0;
604
  goto __pyx_L0;
603
  goto __pyx_L0;
605
604
606
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
605
  __pyx_r = Py_None; Py_INCREF(Py_None);
607
  goto __pyx_L0;
606
  goto __pyx_L0;
608
  __pyx_L1:;
607
  __pyx_L1:;
609
  Py_XDECREF(__pyx_1);
608
  Py_XDECREF(__pyx_1);
Lines 629-635 Link Here
629
  __pyx_1 = 0;
628
  __pyx_1 = 0;
630
  goto __pyx_L0;
629
  goto __pyx_L0;
631
630
632
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
631
  __pyx_r = Py_None; Py_INCREF(Py_None);
633
  goto __pyx_L0;
632
  goto __pyx_L0;
634
  __pyx_L1:;
633
  __pyx_L1:;
635
  Py_XDECREF(__pyx_1);
634
  Py_XDECREF(__pyx_1);
Lines 700-706 Link Here
700
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":227 */
699
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":227 */
701
  pcap_freecode((&__pyx_v_fcode));
700
  pcap_freecode((&__pyx_v_fcode));
702
701
703
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
702
  __pyx_r = Py_None; Py_INCREF(Py_None);
704
  goto __pyx_L0;
703
  goto __pyx_L0;
705
  __pyx_L1:;
704
  __pyx_L1:;
706
  Py_XDECREF(__pyx_4);
705
  Py_XDECREF(__pyx_4);
Lines 730-736 Link Here
730
  __pyx_1 = PyInt_AsLong(__pyx_v_nonblock); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}
729
  __pyx_1 = PyInt_AsLong(__pyx_v_nonblock); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; goto __pyx_L1;}
731
  pcap_ex_setnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
730
  pcap_ex_setnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,__pyx_1,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf);
732
731
733
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
732
  __pyx_r = Py_None; Py_INCREF(Py_None);
734
  goto __pyx_L0;
733
  goto __pyx_L0;
735
  __pyx_L1:;
734
  __pyx_L1:;
736
  __Pyx_AddTraceback("pcap.pcap.setnonblock");
735
  __Pyx_AddTraceback("pcap.pcap.setnonblock");
Lines 752-758 Link Here
752
  static char *__pyx_argnames[] = {0};
751
  static char *__pyx_argnames[] = {0};
753
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
752
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
754
  Py_INCREF(__pyx_v_self);
753
  Py_INCREF(__pyx_v_self);
755
  __pyx_v_ret = Py_None; Py_INCREF(__pyx_v_ret);
754
  __pyx_v_ret = Py_None; Py_INCREF(Py_None);
756
755
757
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":235 */
756
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":235 */
758
  __pyx_1 = PyInt_FromLong(pcap_ex_getnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
757
  __pyx_1 = PyInt_FromLong(pcap_ex_getnonblock(((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__pcap,((struct __pyx_obj_4pcap_pcap *)__pyx_v_self)->__ebuf)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; goto __pyx_L1;}
Lines 794-800 Link Here
794
  __pyx_3 = 0;
793
  __pyx_3 = 0;
795
  goto __pyx_L0;
794
  goto __pyx_L0;
796
795
797
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
796
  __pyx_r = Py_None; Py_INCREF(Py_None);
798
  goto __pyx_L0;
797
  goto __pyx_L0;
799
  __pyx_L1:;
798
  __pyx_L1:;
800
  Py_XDECREF(__pyx_1);
799
  Py_XDECREF(__pyx_1);
Lines 822-828 Link Here
822
  __pyx_1 = 0;
821
  __pyx_1 = 0;
823
  goto __pyx_L0;
822
  goto __pyx_L0;
824
823
825
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
824
  __pyx_r = Py_None; Py_INCREF(Py_None);
826
  goto __pyx_L0;
825
  goto __pyx_L0;
827
  __pyx_L1:;
826
  __pyx_L1:;
828
  Py_XDECREF(__pyx_1);
827
  Py_XDECREF(__pyx_1);
Lines 874-880 Link Here
874
  __pyx_4 = 0;
873
  __pyx_4 = 0;
875
  goto __pyx_L0;
874
  goto __pyx_L0;
876
875
877
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
876
  __pyx_r = Py_None; Py_INCREF(Py_None);
878
  goto __pyx_L0;
877
  goto __pyx_L0;
879
  __pyx_L1:;
878
  __pyx_L1:;
880
  Py_XDECREF(__pyx_2);
879
  Py_XDECREF(__pyx_2);
Lines 920-926 Link Here
920
  Py_DECREF(__pyx_3); __pyx_3 = 0;
919
  Py_DECREF(__pyx_3); __pyx_3 = 0;
921
  Py_DECREF(__pyx_2); __pyx_2 = 0;
920
  Py_DECREF(__pyx_2); __pyx_2 = 0;
922
921
923
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
922
  __pyx_r = Py_None; Py_INCREF(Py_None);
924
  goto __pyx_L0;
923
  goto __pyx_L0;
925
  __pyx_L1:;
924
  __pyx_L1:;
926
  Py_XDECREF(__pyx_1);
925
  Py_XDECREF(__pyx_1);
Lines 951-957 Link Here
951
  static char *__pyx_argnames[] = {0};
950
  static char *__pyx_argnames[] = {0};
952
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
951
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
953
  Py_INCREF(__pyx_v_self);
952
  Py_INCREF(__pyx_v_self);
954
  __pyx_v_pkts = Py_None; Py_INCREF(__pyx_v_pkts);
953
  __pyx_v_pkts = Py_None; Py_INCREF(Py_None);
955
954
956
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":261 */
955
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":261 */
957
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}
956
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; goto __pyx_L1;}
Lines 980-986 Link Here
980
  __pyx_r = __pyx_v_pkts;
979
  __pyx_r = __pyx_v_pkts;
981
  goto __pyx_L0;
980
  goto __pyx_L0;
982
981
983
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
982
  __pyx_r = Py_None; Py_INCREF(Py_None);
984
  goto __pyx_L0;
983
  goto __pyx_L0;
985
  __pyx_L1:;
984
  __pyx_L1:;
986
  Py_XDECREF(__pyx_1);
985
  Py_XDECREF(__pyx_1);
Lines 1023-1029 Link Here
1023
  Py_INCREF(__pyx_v_self);
1022
  Py_INCREF(__pyx_v_self);
1024
  Py_INCREF(__pyx_v_cnt);
1023
  Py_INCREF(__pyx_v_cnt);
1025
  Py_INCREF(__pyx_v_callback);
1024
  Py_INCREF(__pyx_v_callback);
1026
  __pyx_v_exc = Py_None; Py_INCREF(__pyx_v_exc);
1025
  __pyx_v_exc = Py_None; Py_INCREF(Py_None);
1027
1026
1028
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":281 */
1027
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":281 */
1029
  __pyx_v_ctx.callback = ((void (*))__pyx_v_callback);
1028
  __pyx_v_ctx.callback = ((void (*))__pyx_v_callback);
Lines 1046-1072 Link Here
1046
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1045
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1047
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1046
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_exc_info); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1048
    Py_DECREF(__pyx_2); __pyx_2 = 0;
1047
    Py_DECREF(__pyx_2); __pyx_2 = 0;
1049
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1048
    __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1050
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
1051
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1049
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1052
    Py_DECREF(__pyx_2); __pyx_2 = 0;
1053
    Py_DECREF(__pyx_v_exc);
1050
    Py_DECREF(__pyx_v_exc);
1054
    __pyx_v_exc = __pyx_4;
1051
    __pyx_v_exc = __pyx_2;
1055
    __pyx_4 = 0;
1052
    __pyx_2 = 0;
1056
1053
1057
    /* "/Users/dugsong/projects/pypcap/pcap.pyx":288 */
1054
    /* "/Users/dugsong/projects/pypcap/pcap.pyx":288 */
1058
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1055
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1059
    __pyx_2 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1056
    __pyx_2 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1060
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1057
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1061
    __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1058
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1062
    __pyx_3 = PyObject_GetItem(__pyx_v_exc, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1059
    __pyx_4 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1063
    Py_DECREF(__pyx_4); __pyx_4 = 0;
1064
    __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1065
    __pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1066
    Py_DECREF(__pyx_4); __pyx_4 = 0;
1067
    __Pyx_Raise(__pyx_2, __pyx_3, __pyx_5);
1068
    Py_DECREF(__pyx_2); __pyx_2 = 0;
1069
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1060
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1061
    __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1062
    __pyx_5 = PyObject_GetItem(__pyx_v_exc, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1063
    Py_DECREF(__pyx_3); __pyx_3 = 0;
1064
    __Pyx_Raise(__pyx_2, __pyx_4, __pyx_5);
1065
    Py_DECREF(__pyx_2); __pyx_2 = 0;
1066
    Py_DECREF(__pyx_4); __pyx_4 = 0;
1070
    Py_DECREF(__pyx_5); __pyx_5 = 0;
1067
    Py_DECREF(__pyx_5); __pyx_5 = 0;
1071
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1068
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
1072
    goto __pyx_L2;
1069
    goto __pyx_L2;
Lines 1074-1085 Link Here
1074
  __pyx_L2:;
1071
  __pyx_L2:;
1075
1072
1076
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":289 */
1073
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":289 */
1077
  __pyx_4 = PyInt_FromLong(__pyx_v_n); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
1074
  __pyx_3 = PyInt_FromLong(__pyx_v_n); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
1078
  __pyx_r = __pyx_4;
1075
  __pyx_r = __pyx_3;
1079
  __pyx_4 = 0;
1076
  __pyx_3 = 0;
1080
  goto __pyx_L0;
1077
  goto __pyx_L0;
1081
1078
1082
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1079
  __pyx_r = Py_None; Py_INCREF(Py_None);
1083
  goto __pyx_L0;
1080
  goto __pyx_L0;
1084
  __pyx_L1:;
1081
  __pyx_L1:;
1085
  Py_XDECREF(__pyx_2);
1082
  Py_XDECREF(__pyx_2);
Lines 1131-1137 Link Here
1131
1128
1132
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":304 */
1129
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":304 */
1133
  while (1) {
1130
  while (1) {
1134
    __pyx_L2:;
1135
    __pyx_1 = 1;
1131
    __pyx_1 = 1;
1136
    if (!__pyx_1) break;
1132
    if (!__pyx_1) break;
1137
1133
Lines 1186-1192 Link Here
1186
  }
1182
  }
1187
  __pyx_L3:;
1183
  __pyx_L3:;
1188
1184
1189
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1185
  __pyx_r = Py_None; Py_INCREF(Py_None);
1190
  goto __pyx_L0;
1186
  goto __pyx_L0;
1191
  __pyx_L1:;
1187
  __pyx_L1:;
1192
  Py_XDECREF(__pyx_3);
1188
  Py_XDECREF(__pyx_3);
Lines 1218-1224 Link Here
1218
  __pyx_1 = 0;
1214
  __pyx_1 = 0;
1219
  goto __pyx_L0;
1215
  goto __pyx_L0;
1220
1216
1221
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1217
  __pyx_r = Py_None; Py_INCREF(Py_None);
1222
  goto __pyx_L0;
1218
  goto __pyx_L0;
1223
  __pyx_L1:;
1219
  __pyx_L1:;
1224
  Py_XDECREF(__pyx_1);
1220
  Py_XDECREF(__pyx_1);
Lines 1259-1267 Link Here
1259
  __pyx_L2:;
1255
  __pyx_L2:;
1260
1256
1261
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":326 */
1257
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":326 */
1262
  __pyx_2 = PyInt_FromLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1258
  __pyx_2 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_recv); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1263
  __pyx_3 = PyInt_FromLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1259
  __pyx_3 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_drop); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1264
  __pyx_4 = PyInt_FromLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1260
  __pyx_4 = PyLong_FromUnsignedLong(__pyx_v_pstat.ps_ifdrop); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1265
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1261
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
1266
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
1262
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
1267
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
1263
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
Lines 1273-1279 Link Here
1273
  __pyx_5 = 0;
1269
  __pyx_5 = 0;
1274
  goto __pyx_L0;
1270
  goto __pyx_L0;
1275
1271
1276
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1272
  __pyx_r = Py_None; Py_INCREF(Py_None);
1277
  goto __pyx_L0;
1273
  goto __pyx_L0;
1278
  __pyx_L1:;
1274
  __pyx_L1:;
1279
  Py_XDECREF(__pyx_2);
1275
  Py_XDECREF(__pyx_2);
Lines 1300-1310 Link Here
1300
  __pyx_r = __pyx_v_self;
1296
  __pyx_r = __pyx_v_self;
1301
  goto __pyx_L0;
1297
  goto __pyx_L0;
1302
1298
1303
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1299
  __pyx_r = Py_None; Py_INCREF(Py_None);
1304
  goto __pyx_L0;
1305
  __pyx_L1:;
1306
  __Pyx_AddTraceback("pcap.pcap.__iter__");
1307
  __pyx_r = 0;
1308
  __pyx_L0:;
1300
  __pyx_L0:;
1309
  Py_DECREF(__pyx_v_self);
1301
  Py_DECREF(__pyx_v_self);
1310
  return __pyx_r;
1302
  return __pyx_r;
Lines 1327-1333 Link Here
1327
1319
1328
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":336 */
1320
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":336 */
1329
  while (1) {
1321
  while (1) {
1330
    __pyx_L2:;
1331
    __pyx_1 = 1;
1322
    __pyx_1 = 1;
1332
    if (!__pyx_1) break;
1323
    if (!__pyx_1) break;
1333
1324
Lines 1379-1387 Link Here
1379
    }
1370
    }
1380
    __pyx_L4:;
1371
    __pyx_L4:;
1381
  }
1372
  }
1382
  __pyx_L3:;
1383
1373
1384
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1374
  __pyx_r = Py_None; Py_INCREF(Py_None);
1385
  goto __pyx_L0;
1375
  goto __pyx_L0;
1386
  __pyx_L1:;
1376
  __pyx_L1:;
1387
  Py_XDECREF(__pyx_3);
1377
  Py_XDECREF(__pyx_3);
Lines 1429-1438 Link Here
1429
  }
1419
  }
1430
  __pyx_L4:;
1420
  __pyx_L4:;
1431
1421
1432
  goto __pyx_L0;
1433
  __pyx_L1:;
1434
  __Pyx_AddTraceback("pcap.pcap.__dealloc__");
1435
  __pyx_L0:;
1436
  Py_DECREF(__pyx_v_self);
1422
  Py_DECREF(__pyx_v_self);
1437
}
1423
}
1438
1424
Lines 1450-1456 Link Here
1450
  __pyx_1 = 0;
1436
  __pyx_1 = 0;
1451
  goto __pyx_L0;
1437
  goto __pyx_L0;
1452
1438
1453
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1439
  __pyx_r = Py_None; Py_INCREF(Py_None);
1454
  goto __pyx_L0;
1440
  goto __pyx_L0;
1455
  __pyx_L1:;
1441
  __pyx_L1:;
1456
  Py_XDECREF(__pyx_1);
1442
  Py_XDECREF(__pyx_1);
Lines 1476-1482 Link Here
1476
  __pyx_v_p = pcap_ex_lookupdev(__pyx_v_ebuf);
1462
  __pyx_v_p = pcap_ex_lookupdev(__pyx_v_ebuf);
1477
1463
1478
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":363 */
1464
  /* "/Users/dugsong/projects/pypcap/pcap.pyx":363 */
1479
  __pyx_1 = (__pyx_v_p == 0);
1465
  __pyx_1 = (__pyx_v_p == NULL);
1480
  if (__pyx_1) {
1466
  if (__pyx_1) {
1481
1467
1482
    /* "/Users/dugsong/projects/pypcap/pcap.pyx":364 */
1468
    /* "/Users/dugsong/projects/pypcap/pcap.pyx":364 */
Lines 1496-1502 Link Here
1496
  __pyx_2 = 0;
1482
  __pyx_2 = 0;
1497
  goto __pyx_L0;
1483
  goto __pyx_L0;
1498
1484
1499
  __pyx_r = Py_None; Py_INCREF(__pyx_r);
1485
  __pyx_r = Py_None; Py_INCREF(Py_None);
1500
  goto __pyx_L0;
1486
  goto __pyx_L0;
1501
  __pyx_L1:;
1487
  __pyx_L1:;
1502
  Py_XDECREF(__pyx_2);
1488
  Py_XDECREF(__pyx_2);
Lines 1564-1575 Link Here
1564
1550
1565
static PyObject *__pyx_tp_new_4pcap_bpf(PyTypeObject *t, PyObject *a, PyObject *k) {
1551
static PyObject *__pyx_tp_new_4pcap_bpf(PyTypeObject *t, PyObject *a, PyObject *k) {
1566
  PyObject *o = (*t->tp_alloc)(t, 0);
1552
  PyObject *o = (*t->tp_alloc)(t, 0);
1567
  struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;
1568
  return o;
1553
  return o;
1569
}
1554
}
1570
1555
1571
static void __pyx_tp_dealloc_4pcap_bpf(PyObject *o) {
1556
static void __pyx_tp_dealloc_4pcap_bpf(PyObject *o) {
1572
  struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;
1573
  {
1557
  {
1574
    PyObject *etype, *eval, *etb;
1558
    PyObject *etype, *eval, *etb;
1575
    PyErr_Fetch(&etype, &eval, &etb);
1559
    PyErr_Fetch(&etype, &eval, &etb);
Lines 1583-1595 Link Here
1583
}
1567
}
1584
1568
1585
static int __pyx_tp_traverse_4pcap_bpf(PyObject *o, visitproc v, void *a) {
1569
static int __pyx_tp_traverse_4pcap_bpf(PyObject *o, visitproc v, void *a) {
1586
  int e;
1587
  struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;
1588
  return 0;
1570
  return 0;
1589
}
1571
}
1590
1572
1591
static int __pyx_tp_clear_4pcap_bpf(PyObject *o) {
1573
static int __pyx_tp_clear_4pcap_bpf(PyObject *o) {
1592
  struct __pyx_obj_4pcap_bpf *p = (struct __pyx_obj_4pcap_bpf *)o;
1593
  return 0;
1574
  return 0;
1594
}
1575
}
1595
1576
Lines 1665-1671 Link Here
1665
  0, /*bf_getcharbuffer*/
1646
  0, /*bf_getcharbuffer*/
1666
};
1647
};
1667
1648
1668
statichere PyTypeObject __pyx_type_4pcap_bpf = {
1649
PyTypeObject __pyx_type_4pcap_bpf = {
1669
  PyObject_HEAD_INIT(0)
1650
  PyObject_HEAD_INIT(0)
1670
  0, /*ob_size*/
1651
  0, /*ob_size*/
1671
  "pcap.bpf", /*tp_name*/
1652
  "pcap.bpf", /*tp_name*/
Lines 1686-1692 Link Here
1686
  0, /*tp_getattro*/
1667
  0, /*tp_getattro*/
1687
  0, /*tp_setattro*/
1668
  0, /*tp_setattro*/
1688
  &__pyx_tp_as_buffer_bpf, /*tp_as_buffer*/
1669
  &__pyx_tp_as_buffer_bpf, /*tp_as_buffer*/
1689
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
1670
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1690
  "bpf(filter, dlt=DLT_RAW) -> BPF filter object", /*tp_doc*/
1671
  "bpf(filter, dlt=DLT_RAW) -> BPF filter object", /*tp_doc*/
1691
  __pyx_tp_traverse_4pcap_bpf, /*tp_traverse*/
1672
  __pyx_tp_traverse_4pcap_bpf, /*tp_traverse*/
1692
  __pyx_tp_clear_4pcap_bpf, /*tp_clear*/
1673
  __pyx_tp_clear_4pcap_bpf, /*tp_clear*/
Lines 1716-1727 Link Here
1716
1697
1717
static PyObject *__pyx_tp_new_4pcap_pcap(PyTypeObject *t, PyObject *a, PyObject *k) {
1698
static PyObject *__pyx_tp_new_4pcap_pcap(PyTypeObject *t, PyObject *a, PyObject *k) {
1718
  PyObject *o = (*t->tp_alloc)(t, 0);
1699
  PyObject *o = (*t->tp_alloc)(t, 0);
1719
  struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;
1720
  return o;
1700
  return o;
1721
}
1701
}
1722
1702
1723
static void __pyx_tp_dealloc_4pcap_pcap(PyObject *o) {
1703
static void __pyx_tp_dealloc_4pcap_pcap(PyObject *o) {
1724
  struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;
1725
  {
1704
  {
1726
    PyObject *etype, *eval, *etb;
1705
    PyObject *etype, *eval, *etb;
1727
    PyErr_Fetch(&etype, &eval, &etb);
1706
    PyErr_Fetch(&etype, &eval, &etb);
Lines 1735-1747 Link Here
1735
}
1714
}
1736
1715
1737
static int __pyx_tp_traverse_4pcap_pcap(PyObject *o, visitproc v, void *a) {
1716
static int __pyx_tp_traverse_4pcap_pcap(PyObject *o, visitproc v, void *a) {
1738
  int e;
1739
  struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;
1740
  return 0;
1717
  return 0;
1741
}
1718
}
1742
1719
1743
static int __pyx_tp_clear_4pcap_pcap(PyObject *o) {
1720
static int __pyx_tp_clear_4pcap_pcap(PyObject *o) {
1744
  struct __pyx_obj_4pcap_pcap *p = (struct __pyx_obj_4pcap_pcap *)o;
1745
  return 0;
1721
  return 0;
1746
}
1722
}
1747
1723
Lines 1857-1863 Link Here
1857
  0, /*bf_getcharbuffer*/
1833
  0, /*bf_getcharbuffer*/
1858
};
1834
};
1859
1835
1860
statichere PyTypeObject __pyx_type_4pcap_pcap = {
1836
PyTypeObject __pyx_type_4pcap_pcap = {
1861
  PyObject_HEAD_INIT(0)
1837
  PyObject_HEAD_INIT(0)
1862
  0, /*ob_size*/
1838
  0, /*ob_size*/
1863
  "pcap.pcap", /*tp_name*/
1839
  "pcap.pcap", /*tp_name*/
Lines 1878-1884 Link Here
1878
  0, /*tp_getattro*/
1854
  0, /*tp_getattro*/
1879
  0, /*tp_setattro*/
1855
  0, /*tp_setattro*/
1880
  &__pyx_tp_as_buffer_pcap, /*tp_as_buffer*/
1856
  &__pyx_tp_as_buffer_pcap, /*tp_as_buffer*/
1881
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
1857
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1882
  "pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object\n    \n    Open a handle to a packet capture descriptor.\n    \n    Keyword arguments:\n    name      -- name of a network interface or dumpfile to open,\n                 or None to open the first available up interface\n    snaplen   -- maximum number of bytes to capture for each packet\n    promisc   -- boolean to specify promiscuous mode sniffing\n    immediate -- disable buffering, if possible\n    ", /*tp_doc*/
1858
  "pcap(name=None, snaplen=65535, promisc=True, immediate=False) -> packet capture object\n    \n    Open a handle to a packet capture descriptor.\n    \n    Keyword arguments:\n    name      -- name of a network interface or dumpfile to open,\n                 or None to open the first available up interface\n    snaplen   -- maximum number of bytes to capture for each packet\n    promisc   -- boolean to specify promiscuous mode sniffing\n    immediate -- disable buffering, if possible\n    ", /*tp_doc*/
1883
  __pyx_tp_traverse_4pcap_pcap, /*tp_traverse*/
1859
  __pyx_tp_traverse_4pcap_pcap, /*tp_traverse*/
1884
  __pyx_tp_clear_4pcap_pcap, /*tp_clear*/
1860
  __pyx_tp_clear_4pcap_pcap, /*tp_clear*/
Lines 1912-1919 Link Here
1912
  {0, 0, 0, 0}
1888
  {0, 0, 0, 0}
1913
};
1889
};
1914
1890
1915
DL_EXPORT(void) initpcap(void); /*proto*/
1891
static void __pyx_init_filenames(void); /*proto*/
1916
DL_EXPORT(void) initpcap(void) {
1892
1893
PyMODINIT_FUNC initpcap(void); /*proto*/
1894
PyMODINIT_FUNC initpcap(void) {
1917
  PyObject *__pyx_1 = 0;
1895
  PyObject *__pyx_1 = 0;
1918
  PyObject *__pyx_2 = 0;
1896
  PyObject *__pyx_2 = 0;
1919
  PyObject *__pyx_3 = 0;
1897
  PyObject *__pyx_3 = 0;
Lines 1922-1927 Link Here
1922
  PyObject *__pyx_6 = 0;
1900
  PyObject *__pyx_6 = 0;
1923
  PyObject *__pyx_7 = 0;
1901
  PyObject *__pyx_7 = 0;
1924
  PyObject *__pyx_8 = 0;
1902
  PyObject *__pyx_8 = 0;
1903
  __pyx_init_filenames();
1925
  __pyx_m = Py_InitModule4("pcap", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
1904
  __pyx_m = Py_InitModule4("pcap", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
1926
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
1905
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;};
1927
  __pyx_b = PyImport_AddModule("__builtin__");
1906
  __pyx_b = PyImport_AddModule("__builtin__");
Lines 2182-2191 Link Here
2182
static char *__pyx_filenames[] = {
2161
static char *__pyx_filenames[] = {
2183
  "pcap.pyx",
2162
  "pcap.pyx",
2184
};
2163
};
2185
statichere char **__pyx_f = __pyx_filenames;
2186
2164
2187
/* Runtime support code */
2165
/* Runtime support code */
2188
2166
2167
static void __pyx_init_filenames(void) {
2168
  __pyx_f = __pyx_filenames;
2169
}
2170
2189
static int __Pyx_GetStarArgs(
2171
static int __Pyx_GetStarArgs(
2190
    PyObject **args, 
2172
    PyObject **args, 
2191
    PyObject **kwds,
2173
    PyObject **kwds,
Lines 2250-2259 Link Here
2250
bad:
2232
bad:
2251
    Py_XDECREF(args1);
2233
    Py_XDECREF(args1);
2252
    Py_XDECREF(kwds1);
2234
    Py_XDECREF(kwds1);
2253
    if (*args2)
2235
    if (*args2) {
2254
        Py_XDECREF(*args2);
2236
        Py_XDECREF(*args2);
2255
    if (*kwds2)
2237
    }
2238
    if (*kwds2) {
2256
        Py_XDECREF(*kwds2);
2239
        Py_XDECREF(*kwds2);
2240
    }
2257
    return -1;
2241
    return -1;
2258
}
2242
}
2259
2243
Lines 2365-2396 Link Here
2365
        Py_INCREF(type);
2349
        Py_INCREF(type);
2366
        Py_DECREF(tmp);
2350
        Py_DECREF(tmp);
2367
    }
2351
    }
2368
    if (PyString_Check(type))
2352
    if (PyString_Check(type)) {
2369
        ;
2353
        if (PyErr_Warn(PyExc_DeprecationWarning,
2370
    else if (PyClass_Check(type))
2354
                "raising a string exception is deprecated"))
2355
            goto raise_error;
2356
    }
2357
    else if (PyType_Check(type) || PyClass_Check(type))
2371
        ; /*PyErr_NormalizeException(&type, &value, &tb);*/
2358
        ; /*PyErr_NormalizeException(&type, &value, &tb);*/
2372
    else if (PyInstance_Check(type)) {
2359
    else {
2373
        /* Raising an instance.  The value should be a dummy. */
2360
        /* Raising an instance.  The value should be a dummy. */
2374
        if (value != Py_None) {
2361
        if (value != Py_None) {
2375
            PyErr_SetString(PyExc_TypeError,
2362
            PyErr_SetString(PyExc_TypeError,
2376
              "instance exception may not have a separate value");
2363
                "instance exception may not have a separate value");
2377
            goto raise_error;
2364
            goto raise_error;
2378
        }
2365
        }
2379
        else {
2366
        /* Normalize to raise <class>, <instance> */
2380
            /* Normalize to raise <class>, <instance> */
2367
        Py_DECREF(value);
2381
            Py_DECREF(value);
2368
        value = type;
2382
            value = type;
2369
        if (PyInstance_Check(type))
2383
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
2370
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
2384
            Py_INCREF(type);
2371
        else
2385
        }
2372
            type = (PyObject*) type->ob_type;
2386
    }
2373
        Py_INCREF(type);
2387
    else {
2388
        /* Not something you can raise.  You get an exception
2389
           anyway, just not what you specified :-) */
2390
        PyErr_Format(PyExc_TypeError,
2391
                 "exceptions must be strings, classes, or "
2392
                 "instances, not %s", type->ob_type->tp_name);
2393
        goto raise_error;
2394
    }
2374
    }
2395
    PyErr_Restore(type, value, tb);
2375
    PyErr_Restore(type, value, tb);
2396
    return;
2376
    return;

Return to bug 180039