Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/_collections_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from abc import ABCMeta, abstractmethod
import sys
import _sys as sys # We use the low-level module during interpreter init.

__all__ = ["Awaitable", "Coroutine",
"AsyncIterable", "AsyncIterator", "AsyncGenerator",
Expand Down
2 changes: 1 addition & 1 deletion Lib/_compat_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
NAME_MAPPING = {
('__builtin__', 'xrange'): ('builtins', 'range'),
('__builtin__', 'reduce'): ('functools', 'reduce'),
('__builtin__', 'intern'): ('sys', 'intern'),
('__builtin__', 'intern'): ('_sys', 'intern'),
('__builtin__', 'unichr'): ('builtins', 'chr'),
('__builtin__', 'unicode'): ('builtins', 'str'),
('__builtin__', 'long'): ('builtins', 'int'),
Expand Down
2 changes: 1 addition & 1 deletion Lib/_sitebuiltins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Note this means this module should also avoid keep things alive in its
# globals.

import sys
import _sys as sys # We use the low-level module during interpreter init.

class Quitter(object):
def __init__(self, name, eof):
Expand Down
2 changes: 1 addition & 1 deletion Lib/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

import builtins
import sys
import _sys as sys # We use the low-level module during interpreter init.

### Registry and builtin stateless codec functions

Expand Down
2 changes: 1 addition & 1 deletion Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from operator import itemgetter as _itemgetter, eq as _eq
from keyword import iskeyword as _iskeyword
import sys as _sys
import _sys # We use the low-level module during interpreter init.
import heapq as _heapq
from _weakref import proxy as _proxy
from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
Expand Down
2 changes: 1 addition & 1 deletion Lib/contextlib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities for with-statement contexts. See PEP 343."""
import abc
import sys
import _sys as sys
import _collections_abc
from collections import deque
from functools import wraps
Expand Down
2 changes: 1 addition & 1 deletion Lib/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _normalize_module(module, depth=2):
elif module is None:
return sys.modules[sys._getframe(depth).f_globals['__name__']]
else:
raise TypeError("Expected a module, string, or None")
raise TypeError("Expected a module, string, or None, got {}".format(type(module)))

def _load_testfile(filename, package, module_relative, encoding):
if module_relative:
Expand Down
2 changes: 1 addition & 1 deletion Lib/encodings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"""#"

import codecs
import sys
import _sys as sys
from . import aliases

_cache = {}
Expand Down
2 changes: 1 addition & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys
import _sys as sys
from types import MappingProxyType, DynamicClassAttribute
from functools import reduce
from operator import or_ as _or_
Expand Down
2 changes: 1 addition & 1 deletion Lib/importlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# of a fully initialised version (either the frozen one or the one
# initialised below if the frozen one is not available).
import _imp # Just the builtin component, NOT the full Python module
import sys
import _sys as sys

try:
import _frozen_importlib as _bootstrap
Expand Down
4 changes: 2 additions & 2 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ def _find_parent_path_names(self):
"""Returns a tuple of (parent-module-name, parent-path-attr-name)"""
parent, dot, me = self._name.rpartition('.')
if dot == '':
# This is a top-level module. sys.path contains the parent path.
return 'sys', 'path'
# This is a top-level module. _sys.path contains the parent path.
return '_sys', 'path'
# Not a top-level module. parent-module.__path__ contains the
# parent path.
return parent, '__path__'
Expand Down
2 changes: 1 addition & 1 deletion Lib/importlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from contextlib import contextmanager
import functools
import sys
import _sys as sys
import types
import warnings

Expand Down
2 changes: 1 addition & 1 deletion Lib/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

"""

import sys
import _sys as sys
import encodings
import encodings.aliases
import re
Expand Down
2 changes: 1 addition & 1 deletion Lib/ntpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import os
import sys
import _sys as sys # We use the low-level module during interpreter init.
import stat
import genericpath
from genericpath import *
Expand Down
3 changes: 2 additions & 1 deletion Lib/optparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

import sys, os
import os
import _sys as sys
import textwrap

def _repr(self):
Expand Down
3 changes: 2 additions & 1 deletion Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

#'
import abc
import sys, errno
import errno
import _sys as sys # We use the low-level module during interpreter init.
import stat as st

_names = sys.builtin_module_names
Expand Down
2 changes: 1 addition & 1 deletion Lib/pkgutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import importlib.machinery
import os
import os.path
import sys
import _sys as sys
from types import ModuleType
import warnings

Expand Down
2 changes: 1 addition & 1 deletion Lib/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

import os
import sys
import _sys as sys # We use the low-level module during interpreter init.
import stat
import genericpath
from genericpath import *
Expand Down
2 changes: 1 addition & 1 deletion Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def getdocloc(self, object,
basedir = os.path.normcase(basedir)
if (isinstance(object, type(os)) and
(object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
'marshal', 'posix', 'signal', 'sys',
'marshal', 'posix', 'signal', '_sys',
'_thread', 'zipimport') or
(file.startswith(basedir) and
not file.startswith(os.path.join(basedir, 'site-packages')))) and
Expand Down
2 changes: 1 addition & 1 deletion Lib/runpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# to implement PEP 338 (Executing Modules as Scripts)


import sys
import _sys as sys # the low-level module
import importlib.machinery # importlib first so we can test #15386 via -m
import importlib.util
import types
Expand Down
2 changes: 1 addition & 1 deletion Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
ImportError exception, it is silently ignored.
"""

import sys
import _sys as sys # We use the low-level module during interpreter init.
import os
import builtins
import _sitebuiltins
Expand Down
51 changes: 51 additions & 0 deletions Lib/sys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""This module provides access to some objects used or maintained by the
interpreter and to functions that interact strongly with the interpreter.

This is a wrapper around the low-level _sys module.
"""

import _sys


MODULE_ATTRS = [
"__name__",
"__doc__",
"__loader__",
"__spec__",
"__package__",
# not in _sys:
"__file__",
"__cached__",
"__builtins__",
]


# For now we strictly proxy _sys.

class SysModule(type(_sys)):

# XXX What about cases of "moduletype = type(sys)"?

def __init__(self, name, *, _ns=None):
super().__init__(name)

if _ns is not None:
for attr in MODULE_ATTRS:
object.__setattr__(self, name, _ns[attr])

def __dir__(self):
return sorted(dir(_sys) + MODULE_ATTRS)

def __getattr__(self, name):
return getattr(_sys, name)

def __setattr__(self, name, value):
# XXX Only wrap existing attrs?
setattr(_sys, name, value)

def __delattr__(self, name):
# XXX Only wrap existing attrs?
delattr(_sys, name)


_sys.modules[__name__] = SysModule(__name__, _ns=vars())
2 changes: 1 addition & 1 deletion Lib/sysconfig.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Access to Python's configuration information."""

import os
import sys
import _sys as sys # We use the low-level module during interpreter init.
from os.path import pardir, realpath

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import stat
import struct
import subprocess
import sys
import _sys as sys
import sysconfig
import tempfile
import _thread
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/script_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import collections
import importlib
import sys
import _sys as sys
import os
import os.path
import subprocess
Expand Down
Loading