Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
b50c4326c73f
Commit
2060df4d
authored
Oct 29, 2019
by
Armin Rigo
Browse files
Import posix directly instead of os; import nt on win32
parent
037744e9abc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
pypy/module/_demo/app_demo.py
View file @
b50c4326
# import posix underneath
from
os
import
environ
import
sys
if
sys
.
platform
==
'win32'
:
import
nt
as
posix
else
:
import
posix
# for the test_random_stuff_can_unfreeze test
environ
[
'PYPY_DEMO_MODULE_ERROR'
]
=
'1'
posix
.
environ
[
'PYPY_DEMO_MODULE_ERROR'
]
=
'1'
class
DemoError
(
Exception
):
pass
pypy/module/_demo/test/test_import.py
View file @
b50c4326
import
sys
from
pypy.module._demo.moduledef
import
Module
from
pypy.tool.option
import
make_config
,
make_objspace
...
...
@@ -29,8 +30,11 @@ class TestImport:
assert
space
.
getattr
(
w_demo
,
space
.
wrap
(
'measuretime'
))
posixname
=
'posix'
if
sys
.
platform
!=
'win32'
else
'nt'
class
TestMixedModuleUnfreeze
:
spaceconfig
=
dict
(
usemodules
=
(
'_demo'
,
'
posix
'
))
spaceconfig
=
dict
(
usemodules
=
(
'_demo'
,
posix
name
))
def
test_random_stuff_can_unfreeze
(
self
):
# When a module contains an "import" statement in applevel code, the
...
...
@@ -40,7 +44,7 @@ class TestMixedModuleUnfreeze:
# This is important when the module startup() function does something
# at runtime, like setting os.environ (posix module) or initializing
# the winsock library (_socket module)
w_posix
=
self
.
space
.
builtin_modules
[
'
posix
'
]
w_posix
=
self
.
space
.
builtin_modules
[
posix
name
]
w_demo
=
self
.
space
.
builtin_modules
[
'_demo'
]
w_posix
.
_cleanup_
()
...
...
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