Commit 0d4ecef8 authored by Dong-hee Na's avatar Dong-hee Na

fix and add test

parent dda4b74f
...@@ -569,6 +569,7 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept { ...@@ -569,6 +569,7 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept {
Py_ssize_t dictoffset; Py_ssize_t dictoffset;
PyTypeObject* tp = Py_TYPE(obj); PyTypeObject* tp = Py_TYPE(obj);
if (!tp->instancesHaveHCAttrs()) {
dictoffset = tp->tp_dictoffset; dictoffset = tp->tp_dictoffset;
if (dictoffset == 0) if (dictoffset == 0)
return NULL; return NULL;
...@@ -586,6 +587,10 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept { ...@@ -586,6 +587,10 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept {
assert(dictoffset % SIZEOF_VOID_P == 0); assert(dictoffset % SIZEOF_VOID_P == 0);
} }
return (PyObject**)((char*)obj + dictoffset); return (PyObject**)((char*)obj + dictoffset);
} else {
fatalOrError(PyExc_NotImplementedError, "unimplemented for hcattrs");
return nullptr;
}
} }
/* These methods are used to control infinite recursion in repr, str, print, /* These methods are used to control infinite recursion in repr, str, print,
......
...@@ -2,6 +2,16 @@ ...@@ -2,6 +2,16 @@
# Doesn't test much of the functionality, but even importing the module is tough: # Doesn't test much of the functionality, but even importing the module is tough:
import datetime import datetime
def typeErrorTest(val):
try:
x = datetime.timedelta(43)
x // val
except TypeError as e:
return True
return False
print repr(datetime.time()) print repr(datetime.time())
print datetime.datetime.__base__ print datetime.datetime.__base__
print repr(datetime.datetime(1, 2, 3)) print repr(datetime.datetime(1, 2, 3))
...@@ -11,3 +21,8 @@ print str(datetime.timedelta(0)) ...@@ -11,3 +21,8 @@ print str(datetime.timedelta(0))
datetime.datetime.now().now() datetime.datetime.now().now()
print datetime.datetime(1924, 2, 3).strftime("%B %d, %Y - %X") print datetime.datetime(1924, 2, 3).strftime("%B %d, %Y - %X")
a = 3
b = 3.4
assert not typeErrorTest(a)
assert typeErrorTest(b)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment