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
754ddae3
Commit
754ddae3
authored
Sep 27, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for typing.py and get it working
parent
3f1a0e18
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
7 deletions
+62
-7
src/asm_writing/icinfo.cpp
src/asm_writing/icinfo.cpp
+8
-3
src/runtime/hiddenclass.h
src/runtime/hiddenclass.h
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+3
-1
src/runtime/set.cpp
src/runtime/set.cpp
+2
-2
src/runtime/types.cpp
src/runtime/types.cpp
+6
-1
test/integration/typing_test.py
test/integration/typing_test.py
+42
-0
No files found.
src/asm_writing/icinfo.cpp
View file @
754ddae3
...
...
@@ -41,9 +41,14 @@ int64_t ICInvalidator::version() {
}
ICInvalidator
::~
ICInvalidator
()
{
for
(
ICSlotInfo
*
slot
:
dependents
)
{
slot
->
invalidators
.
erase
(
std
::
find
(
slot
->
invalidators
.
begin
(),
slot
->
invalidators
.
end
(),
this
));
}
// It's not clear what we should do if there are any dependencies still tracked
// when this object is deleted. The most likely thing is that we should invalidate
// them, since whatever caused the destruction is most likely an invalidation event
// as well.
// For now, let's just assert on this to know if it happens. In the unlikely
// case that we want to just ignore any existing dependents (old behavior), we
// can add a new API call to forget them (and remove from the dependents' `invalidators` list)
ASSERT
(
dependents
.
empty
(),
"dependents left when ICInvalidator destructed"
);
}
void
ICInvalidator
::
addDependent
(
ICSlotInfo
*
entry_info
)
{
...
...
src/runtime/hiddenclass.h
View file @
754ddae3
...
...
@@ -165,6 +165,7 @@ public:
void
appendAttrwrapper
();
void
delAttribute
(
BoxedString
*
attr
);
void
addDependence
(
Rewriter
*
rewriter
);
void
invalidateAll
()
{
dependent_getattrs
.
invalidateAll
();
}
friend
class
HiddenClass
;
};
...
...
src/runtime/objmodel.cpp
View file @
754ddae3
...
...
@@ -1318,8 +1318,10 @@ void HCAttrs::_clearRaw() noexcept {
auto
old_attr_list_size
=
hcls
->
attributeArraySize
();
// singleton classes will not get reused so free it
if
(
hcls
->
type
==
HiddenClass
::
SINGLETON
)
if
(
hcls
->
type
==
HiddenClass
::
SINGLETON
)
{
hcls
->
getAsSingleton
()
->
invalidateAll
();
delete
hcls
;
}
new
((
void
*
)
this
)
HCAttrs
(
NULL
);
if
(
old_attr_list
)
{
...
...
src/runtime/set.cpp
View file @
754ddae3
...
...
@@ -158,7 +158,7 @@ BoxedSet* makeNewSet(BoxedClass* cls, Box* container) {
}
Box
*
frozensetNew
(
Box
*
_cls
,
Box
*
container
,
BoxedDict
*
kwargs
)
{
RELEASE_ASSERT
(
_cls
->
cls
==
type_cls
,
""
);
RELEASE_ASSERT
(
PyType_Check
(
_cls
)
,
""
);
BoxedClass
*
cls
=
static_cast
<
BoxedClass
*>
(
_cls
);
RELEASE_ASSERT
(
isSubclass
(
cls
,
frozenset_cls
),
""
);
if
(
_cls
==
frozenset_cls
&&
!
_PyArg_NoKeywords
(
"frozenset()"
,
kwargs
))
{
...
...
@@ -191,7 +191,7 @@ Box* frozensetNew(Box* _cls, Box* container, BoxedDict* kwargs) {
}
Box
*
setNew
(
Box
*
_cls
,
Box
*
container
,
BoxedDict
*
kwargs
)
{
RELEASE_ASSERT
(
_cls
->
cls
==
type_cls
,
""
);
RELEASE_ASSERT
(
PyType_Check
(
_cls
)
,
""
);
BoxedClass
*
cls
=
static_cast
<
BoxedClass
*>
(
_cls
);
RELEASE_ASSERT
(
isSubclass
(
cls
,
set_cls
),
""
);
...
...
src/runtime/types.cpp
View file @
754ddae3
...
...
@@ -1604,7 +1604,11 @@ static Box* function_new(BoxedClass* cls, Box* _code, Box* globals, Box** _args)
Box
*
defaults
=
_args
[
1
];
Box
*
closure
=
_args
[
2
];
RELEASE_ASSERT
(
PyCode_Check
(
_code
),
""
);
if
(
!
PyCode_Check
(
_code
))
{
PyErr_Format
(
TypeError
,
"function() argument 1 must be code, not %200s"
,
_code
->
cls
->
tp_name
);
return
NULL
;
}
BoxedCode
*
code
=
static_cast
<
BoxedCode
*>
(
_code
);
if
(
name
!=
Py_None
&&
!
PyString_Check
(
name
))
{
...
...
@@ -4230,6 +4234,7 @@ void setupRuntime() {
none_cls
->
giveAttr
(
"__base__"
,
object_cls
);
Py_INCREF
(
Py_None
);
object_cls
->
giveAttr
(
"__base__"
,
Py_None
);
object_cls
->
giveAttr
(
"__doc__"
,
boxString
(
"The most base type"
));
// Not sure why CPython defines sizeof(PyTupleObject) to include one element,
// but we copy that, which means we have to subtract that extra pointer to get the tp_basicsize:
...
...
test/integration/typing_test.py
0 → 100644
View file @
754ddae3
import
os
,
sys
,
subprocess
,
shutil
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
)
+
"/../lib"
)
from
test_helper
import
create_virtenv
,
run_test
ENV_NAME
=
"typing_test_env_"
+
os
.
path
.
basename
(
sys
.
executable
)
ENV_DIR
=
os
.
path
.
abspath
(
ENV_NAME
)
PYTHON_EXE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"bin"
,
"python"
))
pkg
=
[
"typing==3.5.2.2"
]
# pkg = ["git+https://github.com/python/typing.git@3.5.2.2"]
create_virtenv
(
ENV_NAME
,
pkg
,
force_create
=
False
)
# subprocess.check_call([PYTHON_EXE, os.path.join(ENV_DIR, "lib", "python2.7", "site-packages", "typing", "test_typing.py")])
# subprocess.check_call([PYTHON_EXE, "-m", "test_typing"])
print
"Running some extra tests:"
test_fn
=
os
.
path
.
join
(
ENV_DIR
,
"test.py"
)
with
open
(
test_fn
,
'w'
)
as
f
:
f
.
write
(
"""
import sys
from typing import Generic, TypeVar, Sequence
RR = TypeVar('RR')
for i in xrange(1000):
Generic[RR]
Sequence[RR]
print "Passed"
"""
)
subprocess
.
check_call
([
PYTHON_EXE
,
test_fn
])
print
"Running typing's own tests:"
import
urllib
test_file
=
urllib
.
urlopen
(
"https://raw.githubusercontent.com/python/typing/1e4c0bae6f797ee5878ce4bb30f3b03c679e3e11/python2/test_typing.py"
).
read
()
test_fn
=
os
.
path
.
join
(
ENV_DIR
,
"test_typing.py"
)
with
open
(
test_fn
,
'w'
)
as
f
:
f
.
write
(
test_file
)
subprocess
.
check_call
([
PYTHON_EXE
,
test_fn
])
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