1
1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
2
## ICUtzinfo-not-heap-type.dpatch by Jakub Wilk <jwilk@debian.org>
4
## DP: Revert upstream change to make ICUtzinfo a heap type.
4
## DP: Fix bug with default tzinfo set on ICUtzinfo type.
5
5
## DP: See https://bugzilla.osafoundation.org/show_bug.cgi?id=13038
7
diff --git a/common.cpp b/common.cpp
8
index e9d704f..84099eb 100644
13
static PyObject *utcoffset_NAME;
14
static PyObject *toordinal_NAME;
15
+static PyObject *getDefault_NAME;
19
@@ -355,7 +356,7 @@ EXPORT UDate PyObject_AsUDate(PyObject *object)
20
PyObject *m = PyImport_ImportModule("icu");
21
PyObject *cls = PyObject_GetAttrString(m, "ICUtzinfo");
23
- tzinfo = PyObject_GetAttrString(cls, "default");
24
+ tzinfo = PyObject_CallMethodObjArgs(cls, getDefault_NAME, NULL);
28
@@ -1241,4 +1242,5 @@ void _init_common(PyObject *m)
30
utcoffset_NAME = PyString_FromString("utcoffset");
31
toordinal_NAME = PyString_FromString("toordinal");
32
+ getDefault_NAME = PyString_FromString("getDefault");
34
diff --git a/setup.py b/setup.py
35
index 86d0253..329ce57 100644
38
@@ -25,6 +25,15 @@ CFLAGS = {
39
'sunos5': ['-DPYICU_VER="%s"' %(VERSION)],
42
+# added to CFLAGS when setup is invoked with --debug
44
+ 'darwin': ['-O0', '-g', '-DDEBUG'],
45
+ 'linux': ['-O0', '-g', '-DDEBUG'],
46
+ 'freebsd7': ['-O0', '-g', '-DDEBUG'],
47
+ 'win32': ['/Od', '/DDEBUG'],
48
+ 'sunos5': ['-DDEBUG'],
52
'darwin': ['-L/usr/local/lib'],
54
@@ -55,6 +64,12 @@ if 'PYICU_CFLAGS' in os.environ:
56
_cflags = CFLAGS[platform]
58
+if '--debug' in sys.argv:
59
+ if 'PYICU_DEBUG_CFLAGS' in os.environ:
60
+ _cflags += os.environ['PYICU_DEBUG_CFLAGS'].split(os.pathsep)
62
+ _cflags += DEBUG_CFLAGS[platform]
64
if 'PYICU_LFLAGS' in os.environ:
65
_lflags = os.environ['PYICU_LFLAGS'].split(os.pathsep)
7
67
diff --git a/tzinfo.cpp b/tzinfo.cpp
68
index 2113b82..046faf1 100644
71
@@ -122,7 +122,6 @@ PyTypeObject TZInfoType = {
11
72
0, /* tp_setattro */
12
73
0, /* tp_as_buffer */
13
74
(Py_TPFLAGS_DEFAULT |
15
76
Py_TPFLAGS_BASETYPE), /* tp_flags */
17
78
0, /* tp_traverse */
79
@@ -445,7 +444,6 @@ static PyObject *t_tzinfo__resetDefault(PyTypeObject *cls)
20
81
Py_XDECREF((PyObject *) _default);
21
82
_default = (t_tzinfo *) tzinfo;
22
83
- PyObject_SetAttrString((PyObject *)&TZInfoType, "default", tzinfo);
23
+ PyDict_SetItemString(TZInfoType.tp_dict, "default", tzinfo);
87
@@ -488,7 +486,6 @@ static PyObject *t_tzinfo_setDefault(PyTypeObject *cls, PyObject *arg)
90
_default = (t_tzinfo *) arg;
91
- PyDict_SetItemString(TZInfoType.tp_dict, "default", arg);
95
@@ -719,10 +716,7 @@ void _init_tzinfo(PyObject *m)
96
PyObject_Call((PyObject *) &FloatingTZType, args, NULL);
98
if (floating && PyObject_TypeCheck(floating, &FloatingTZType))
100
_floating = (t_tzinfo *) floating;
101
- PyDict_SetItemString(TZInfoType.tp_dict, "floating", floating);
104
Py_XDECREF(floating);
106
diff --git a/tzinfo.h b/tzinfo.h
107
index e129465..182459f 100644
114
-extern PyTypeObject TZInfoType;
116
void _init_tzinfo(PyObject *m);
118
#endif /* _tzinfo_h */