Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
0d4ecef8
Commit
0d4ecef8
authored
Jan 31, 2016
by
Dong-hee Na
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix and add test
parent
dda4b74f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
16 deletions
+36
-16
src/capi/object.cpp
src/capi/object.cpp
+21
-16
test/tests/datetime_test.py
test/tests/datetime_test.py
+15
-0
No files found.
src/capi/object.cpp
View file @
0d4ecef8
...
...
@@ -569,23 +569,28 @@ extern "C" PyObject** _PyObject_GetDictPtr(PyObject* obj) noexcept {
Py_ssize_t
dictoffset
;
PyTypeObject
*
tp
=
Py_TYPE
(
obj
);
dictoffset
=
tp
->
tp_dictoffset
;
if
(
dictoffset
==
0
)
return
NULL
;
if
(
dictoffset
<
0
)
{
Py_ssize_t
tsize
;
size_t
size
;
tsize
=
((
PyVarObject
*
)
obj
)
->
ob_size
;
if
(
tsize
<
0
)
tsize
=
-
tsize
;
size
=
_PyObject_VAR_SIZE
(
tp
,
tsize
);
dictoffset
+=
(
long
)
size
;
assert
(
dictoffset
>
0
);
assert
(
dictoffset
%
SIZEOF_VOID_P
==
0
);
if
(
!
tp
->
instancesHaveHCAttrs
())
{
dictoffset
=
tp
->
tp_dictoffset
;
if
(
dictoffset
==
0
)
return
NULL
;
if
(
dictoffset
<
0
)
{
Py_ssize_t
tsize
;
size_t
size
;
tsize
=
((
PyVarObject
*
)
obj
)
->
ob_size
;
if
(
tsize
<
0
)
tsize
=
-
tsize
;
size
=
_PyObject_VAR_SIZE
(
tp
,
tsize
);
dictoffset
+=
(
long
)
size
;
assert
(
dictoffset
>
0
);
assert
(
dictoffset
%
SIZEOF_VOID_P
==
0
);
}
return
(
PyObject
**
)((
char
*
)
obj
+
dictoffset
);
}
else
{
fatalOrError
(
PyExc_NotImplementedError
,
"unimplemented for hcattrs"
);
return
nullptr
;
}
return
(
PyObject
**
)((
char
*
)
obj
+
dictoffset
);
}
/* These methods are used to control infinite recursion in repr, str, print,
...
...
test/tests/datetime_test.py
View file @
0d4ecef8
...
...
@@ -2,6 +2,16 @@
# Doesn't test much of the functionality, but even importing the module is tough:
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
datetime
.
datetime
.
__base__
print
repr
(
datetime
.
datetime
(
1
,
2
,
3
))
...
...
@@ -11,3 +21,8 @@ print str(datetime.timedelta(0))
datetime
.
datetime
.
now
().
now
()
print
datetime
.
datetime
(
1924
,
2
,
3
).
strftime
(
"%B %d, %Y - %X"
)
a
=
3
b
=
3.4
assert
not
typeErrorTest
(
a
)
assert
typeErrorTest
(
b
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment