Skip to content

Commit c35c24c

Browse files
committed
Fix C extensions for Windows
1 parent d32f5df commit c35c24c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pendulum/_extensions/_helpers.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
#include <string.h>
1010
#include <time.h>
1111

12-
#ifndef PyVarObject_HEAD_INIT
13-
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
14-
#endif
15-
1612
/* ------------------------------------------------------------------------- */
1713

1814
#define EPOCH_YEAR 1970
@@ -422,7 +418,7 @@ PyObject* timestamp(PyObject *self, PyObject *args) {
422418
result *= 60;
423419
result += second;
424420

425-
return PyLong_FromLong(result);
421+
return PyLong_FromSsize_t(result);
426422
}
427423

428424
PyObject* local_time(PyObject *self, PyObject *args) {

pendulum/helpers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
from __future__ import absolute_import
22

33
import pendulum
4+
import os
45

56
from math import copysign
67
from datetime import datetime, date, timedelta
78
from contextlib import contextmanager
89
from typing import Union
910

11+
with_extensions = os.getenv("PENDULUM_EXTENSIONS", "1") == "1"
1012

1113
try:
14+
if not with_extensions:
15+
raise ImportError()
16+
1217
from ._extensions._helpers import (
1318
local_time,
1419
precise_diff,

0 commit comments

Comments
 (0)