Author: Armin Rigo <[email protected]>
Branch:
Changeset: r97885:b50c4326c73f
Date: 2019-10-29 17:01 +0100
http://bitbucket.org/pypy/pypy/changeset/b50c4326c73f/
Log: Import posix directly instead of os; import nt on win32
diff --git a/pypy/module/_demo/app_demo.py b/pypy/module/_demo/app_demo.py
--- a/pypy/module/_demo/app_demo.py
+++ b/pypy/module/_demo/app_demo.py
@@ -1,8 +1,12 @@
-# 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
diff --git a/pypy/module/_demo/test/test_import.py
b/pypy/module/_demo/test/test_import.py
--- a/pypy/module/_demo/test/test_import.py
+++ b/pypy/module/_demo/test/test_import.py
@@ -1,3 +1,4 @@
+import sys
from pypy.module._demo.moduledef import Module
from pypy.tool.option import make_config, make_objspace
@@ -29,8 +30,11 @@
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', posixname))
def test_random_stuff_can_unfreeze(self):
# When a module contains an "import" statement in applevel code, the
@@ -40,7 +44,7 @@
# 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[posixname]
w_demo = self.space.builtin_modules['_demo']
w_posix._cleanup_()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit