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
d150b6e3
Commit
d150b6e3
authored
Jul 19, 2016
by
Kevin Modzelewski
Committed by
GitHub
Jul 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1300 from kmod/func_globals
Have function.func_globals always be dict-like
parents
6a33d150
ffa33019
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
2 deletions
+53
-2
src/runtime/types.cpp
src/runtime/types.cpp
+5
-0
test/extra/cffi_test.py
test/extra/cffi_test.py
+2
-2
test/integration/pytest_test.py
test/integration/pytest_test.py
+30
-0
test/tests/functions.py
test/tests/functions.py
+16
-0
No files found.
src/runtime/types.cpp
View file @
d150b6e3
...
...
@@ -305,6 +305,9 @@ extern "C" BoxedFunctionBase::BoxedFunctionBase(FunctionMetadata* md, llvm::Arra
doc
(
NULL
)
{
assert
((
!
globals
)
==
(
!
md
->
source
||
md
->
source
->
scoping
->
areGlobalsFromModule
()));
if
(
globals
)
ASSERT
(
globals
->
cls
==
dict_cls
||
globals
->
cls
==
module_cls
,
"%s"
,
globals
->
cls
->
tp_name
);
Py_XINCREF
(
closure
);
Py_XINCREF
(
globals
);
...
...
@@ -1699,6 +1702,8 @@ static Box* function_globals(Box* self, void*) noexcept {
BoxedFunction
*
func
=
static_cast
<
BoxedFunction
*>
(
self
);
if
(
func
->
globals
)
{
assert
(
!
func
->
md
->
source
||
!
func
->
md
->
source
->
scoping
->
areGlobalsFromModule
());
if
(
func
->
globals
->
cls
==
module_cls
)
return
incref
(
func
->
globals
->
getAttrWrapper
());
return
incref
(
func
->
globals
);
}
assert
(
func
->
md
->
source
);
...
...
test/extra/cffi_test.py
View file @
d150b6e3
...
...
@@ -25,9 +25,9 @@ def install_and_test_cffi():
# looks like clang 3.5 causes more errors like: 214 != -42 doing casts
if
os
.
environ
.
has_key
(
"CC"
)
and
"clang"
in
os
.
environ
[
"CC"
]:
expected
=
[{
"failed"
:
20
,
"passed"
:
165
7
,
"skipped"
:
70
,
"xfailed"
:
4
,
"error"
:
5
}]
expected
=
[{
"failed"
:
20
,
"passed"
:
165
9
,
"skipped"
:
73
,
"xfailed"
:
4
}]
else
:
expected
=
[{
"failed"
:
11
,
"passed"
:
166
6
,
"skipped"
:
70
,
"xfailed"
:
4
,
"error"
:
5
}]
expected
=
[{
"failed"
:
11
,
"passed"
:
166
8
,
"skipped"
:
73
,
"xfailed"
:
4
}]
run_test
([
PYTEST_EXE
],
cwd
=
CFFI_DIR
,
expected
=
expected
)
create_virtenv
(
ENV_NAME
,
[
"pytest==2.8.7"
,
"py==1.4.31"
,
"pycparser==2.14"
],
force_create
=
True
)
...
...
test/integration/pytest_test.py
0 → 100644
View file @
d150b6e3
import
os
,
sys
,
subprocess
,
shutil
sys
.
path
.
append
(
os
.
path
.
dirname
(
__file__
)
+
"/../lib"
)
from
test_helper
import
create_virtenv
,
run_test
ENV_NAME
=
"pytest_test_env_"
+
os
.
path
.
basename
(
sys
.
executable
)
ENV_DIR
=
os
.
path
.
abspath
(
ENV_NAME
)
SRC_DIR
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"src"
))
PYTHON_EXE
=
os
.
path
.
abspath
(
os
.
path
.
join
(
ENV_NAME
,
"bin"
,
"python"
))
pkg
=
[
"pytest==2.8.2"
]
create_virtenv
(
ENV_NAME
,
pkg
)
PYTEST_DIR
=
os
.
path
.
abspath
(
os
.
path
.
join
(
SRC_DIR
,
"pytest"
))
test_dir
=
os
.
path
.
join
(
ENV_DIR
,
"tests"
)
if
not
os
.
path
.
exists
(
test_dir
):
os
.
mkdir
(
test_dir
)
with
open
(
os
.
path
.
join
(
test_dir
,
"test_foo.py"
),
'w'
)
as
f
:
f
.
write
(
"""
import pytest
@pytest.mark.skipif(True, reason="for fun")
def test_skipif_true():
1/0
"""
)
subprocess
.
check_call
([
os
.
path
.
join
(
ENV_DIR
,
"bin"
,
"py.test"
),
test_dir
])
# subprocess.check_call(["gdb", "--args", PYTHON_EXE, "-m", "pytest", test_dir])
test/tests/functions.py
View file @
d150b6e3
...
...
@@ -97,3 +97,19 @@ g2 = copyfunc(g)
assert
g
.
func_defaults
==
g2
.
func_defaults
,
(
g
.
func_defaults
,
g2
.
func_defaults
)
g
(
1
)
g2
(
2
)
# Regression test: make sure that __globals__/func_globals gets set
# properly in exec cases
d
=
{}
exec
"""
def f():
pass
"""
in
d
assert
type
(
d
[
'f'
].
__globals__
)
==
dict
exec
"""
def f():
pass
"""
in
globals
()
assert
type
(
globals
()[
'f'
].
__globals__
)
==
type
(
globals
())
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