Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r84007:9284beb465a0
Date: 2016-04-28 15:19 +0200
http://bitbucket.org/pypy/pypy/changeset/9284beb465a0/
Log: Define PyDateTime_TZInfo struct, and the corresponding Check()
functions.
diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py
--- a/pypy/module/cpyext/cdatetime.py
+++ b/pypy/module/cpyext/cdatetime.py
@@ -92,6 +92,7 @@
make_check_function("PyDate_Check", "date")
make_check_function("PyTime_Check", "time")
make_check_function("PyDelta_Check", "timedelta")
+make_check_function("PyTZInfo_Check", "tzinfo")
# Constructors
diff --git a/pypy/module/cpyext/include/datetime.h
b/pypy/module/cpyext/include/datetime.h
--- a/pypy/module/cpyext/include/datetime.h
+++ b/pypy/module/cpyext/include/datetime.h
@@ -37,6 +37,10 @@
PyObject_HEAD
} PyDateTime_DateTime;
+typedef struct {
+ PyObject_HEAD
+} PyDateTime_TZInfo;
+
#ifdef __cplusplus
}
#endif
diff --git a/pypy/module/cpyext/test/test_datetime.py
b/pypy/module/cpyext/test/test_datetime.py
--- a/pypy/module/cpyext/test/test_datetime.py
+++ b/pypy/module/cpyext/test/test_datetime.py
@@ -72,6 +72,16 @@
date = datetime.datetime.fromtimestamp(0)
assert space.unwrap(space.str(w_date)) == str(date)
+ def test_tzinfo(self, space, api):
+ w_tzinfo = space.appexec(
+ [], """():
+ from datetime import tzinfo
+ return tzinfo()
+ """)
+ assert api.PyTZInfo_Check(w_tzinfo)
+ assert api.PyTZInfo_CheckExact(w_tzinfo)
+ assert not api.PyTZInfo_Check(space.w_None)
+
class AppTestDatetime(AppTestCpythonExtensionBase):
def test_CAPI(self):
module = self.import_extension('foo', [
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit