aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2018-04-24 09:05:26 +0300
committerMatti Picus <matti.picus@gmail.com>2018-04-24 09:05:26 +0300
commit099f9a7a22285f3f6cb17601759eacc86ed4211a (patch)
tree5388e681f52d5eaf0edb06eb3677a77492dc0d32 /pypy/module/cpyext
parentmerge py3.5 into release (diff)
parentmerge default into branch (diff)
downloadpypy-099f9a7a22285f3f6cb17601759eacc86ed4211a.tar.gz
pypy-099f9a7a22285f3f6cb17601759eacc86ed4211a.tar.bz2
pypy-099f9a7a22285f3f6cb17601759eacc86ed4211a.zip
merge py3.5 into releaserelease-pypy3.5-v6.0.0
Diffstat (limited to 'pypy/module/cpyext')
-rw-r--r--pypy/module/cpyext/cdatetime.py2
-rw-r--r--pypy/module/cpyext/test/test_datetime.py18
2 files changed, 15 insertions, 5 deletions
diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py
index ce0bacc004..135f148f08 100644
--- a/pypy/module/cpyext/cdatetime.py
+++ b/pypy/module/cpyext/cdatetime.py
@@ -124,7 +124,7 @@ def init_datetime(space):
# app level datetime.date. If a c-extension class uses datetime.date for its
# base class and defines a tp_dealloc, we will get this:
# c_class->tp_dealloc == tp_dealloc_func
- # c_class->tp_base == datetime.date,
+ # c_class->tp_base == datetime.date,
# datetime.date->tp_dealloc = _PyPy_subtype_dealloc
# datetime.date->tp_base = W_DateTime_Date
# W_DateTime_Date->tp_dealloc = _PyPy_subtype_dealloc
diff --git a/pypy/module/cpyext/test/test_datetime.py b/pypy/module/cpyext/test/test_datetime.py
index cad152e5f2..5f494d9221 100644
--- a/pypy/module/cpyext/test/test_datetime.py
+++ b/pypy/module/cpyext/test/test_datetime.py
@@ -1,3 +1,5 @@
+import pytest
+
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
from pypy.module.cpyext.test.test_api import BaseApiTest
from pypy.module.cpyext.cdatetime import *
@@ -82,6 +84,14 @@ class TestDatetime(BaseApiTest):
date = datetime.datetime.fromtimestamp(0)
assert space.unwrap(space.str(w_date)) == str(date)
+ @pytest.mark.parametrize('name', ['Time', 'DateTime', 'Date', 'Delta'])
+ def test_basicsize(self, space, name):
+ datetime = _PyDateTime_Import(space)
+ py_size = getattr(datetime, "c_%sType" % name).c_tp_basicsize
+ c_size = rffi.sizeof(cts.gettype("PyDateTime_%s" % name))
+ assert py_size == c_size
+
+
class AppTestDatetime(AppTestCpythonExtensionBase):
def test_CAPI(self):
module = self.import_extension('foo', [
@@ -271,9 +281,9 @@ class AppTestDatetime(AppTestCpythonExtensionBase):
6, 6, 6, 6, args, PyDateTimeAPI->TimeType);
"""),
("datetime_with_tzinfo", "METH_O",
- """
+ """
PyObject * obj;
- int tzrefcnt = args->ob_refcnt;
+ int tzrefcnt = args->ob_refcnt;
PyDateTime_IMPORT;
obj = PyDateTimeAPI->DateTime_FromDateAndTime(
2000, 6, 6, 6, 6, 6, 6, args,
@@ -291,7 +301,7 @@ class AppTestDatetime(AppTestCpythonExtensionBase):
return NULL;
}
return obj;
-
+
"""),
], prologue='#include "datetime.h"\n')
from datetime import tzinfo, datetime, timedelta, time
@@ -339,4 +349,4 @@ class AppTestDatetime(AppTestCpythonExtensionBase):
assert module.checks(o) == (True,) * 3 + (False,) * 7 # isinstance(datetime, date)
o = tzinfo()
assert module.checks(o) == (False,) * 8 + (True,) * 2
-
+