~barcc/ubuntu/saucy/pyicu/lp1200419

« back to all changes in this revision

Viewing changes to tzinfo.cpp

  • Committer: Package Import Robot
  • Author(s): Jakub Wilk, Bernd Zeimetz, Jakub Wilk
  • Date: 2011-11-13 12:07:46 UTC
  • mfrom: (3.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20111113120746-20jj2w42dzz6xozt
Tags: 1.3-1
* Team upload.

[ Bernd Zeimetz ]
* Migrate to dh_python2 (closes: #635633).

[ Jakub Wilk ]
* New upstream version.
  + Fix compatiblity with ICU 4.8 (closes: #628584).
  + Rewrite platform-definitions-fix.dpatch from scratch.
  + Revert upstream change to make ICUtzinfo a heap type.
* Bump standards version to 3.9.2 (no changes needed).
* Don't override shared library dependency information for libpython2.X; the
  exension modules aren't linked to it anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
};
103
103
 
104
104
PyTypeObject TZInfoType = {
105
 
    PyObject_HEAD_INIT(NULL)
106
 
    0,                                  /* ob_size */
 
105
    PyVarObject_HEAD_INIT(NULL, 0)
107
106
    "icu.ICUtzinfo",                    /* tp_name */
108
107
    sizeof(t_tzinfo),                   /* tp_basicsize */
109
108
    0,                                  /* tp_itemsize */
123
122
    0,                                  /* tp_setattro */
124
123
    0,                                  /* tp_as_buffer */
125
124
    (Py_TPFLAGS_DEFAULT |
 
125
     Py_TPFLAGS_HEAPTYPE |
126
126
     Py_TPFLAGS_BASETYPE),              /* tp_flags */
127
127
    "",                                 /* tp_doc */
128
128
    0,                                  /* tp_traverse */
185
185
};
186
186
 
187
187
PyTypeObject FloatingTZType = {
188
 
    PyObject_HEAD_INIT(NULL)
189
 
    0,                                  /* ob_size */
 
188
    PyVarObject_HEAD_INIT(NULL, 0)
190
189
    "icu.FloatingTZ",                   /* tp_name */
191
190
    sizeof(t_floatingtz),               /* tp_basicsize */
192
191
    0,                                  /* tp_itemsize */
232
231
static void t_tzinfo_dealloc(t_tzinfo *self)
233
232
{
234
233
    Py_CLEAR(self->tz);
235
 
    self->dt_tzinfo.ob_type->tp_free((PyObject *) self);
 
234
    Py_TYPE(&self->dt_tzinfo)->tp_free((PyObject *) self);
236
235
}
237
236
 
238
237
static void t_floatingtz_dealloc(t_floatingtz *self)
239
238
{
240
239
    Py_CLEAR(self->tzinfo);
241
 
    self->dt_tzinfo.ob_type->tp_free((PyObject *) self);
 
240
    Py_TYPE(&self->dt_tzinfo)->tp_free((PyObject *) self);
242
241
}
243
242
 
244
243
static PyObject *t_tzinfo_new(PyTypeObject *type,
446
445
 
447
446
            Py_XDECREF((PyObject *) _default);
448
447
            _default = (t_tzinfo *) tzinfo;
449
 
            PyDict_SetItemString(TZInfoType.tp_dict, "default", tzinfo);
 
448
            PyObject_SetAttrString((PyObject *)&TZInfoType, "default", tzinfo);
450
449
 
451
450
            Py_RETURN_NONE;
452
451
        }
513
512
        return instance;
514
513
    }
515
514
 
516
 
    if (!PyObject_Compare(id, FLOATING_TZNAME))
 
515
    int cmp = PyObject_RichCompareBool(id, FLOATING_TZNAME, Py_EQ);
 
516
    if (cmp == -1)
 
517
        return NULL;
 
518
    if (cmp)
517
519
        instance = t_tzinfo_getFloating(cls);
518
520
    else
519
521
    {
545
547
    if (!result)
546
548
        return 0.0;
547
549
 
 
550
#if PY_MAJOR_VERSION >= 3
 
551
    unsigned long ordinal = PyLong_AsUnsignedLong(result);
 
552
#else
548
553
    unsigned long ordinal = PyInt_AS_LONG(result);
 
554
#endif
549
555
 
550
556
    Py_DECREF(result);
551
557
    return ((ordinal - 719163) * 86400.0 +