mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
Patch 1267 by Christian Heimes.
Move the initialization of sys.std{in,out,err} and __builtin__.open to C code. This solves the problem that "python -S" wouldn't work.
This commit is contained in:
parent
75a902db78
commit
ce3a72aec6
11 changed files with 175 additions and 31 deletions
12
Lib/io.py
12
Lib/io.py
|
@ -178,6 +178,18 @@ def open(file, mode="r", buffering=None, encoding=None, newline=None):
|
|||
return text
|
||||
|
||||
|
||||
class OpenWrapper:
|
||||
"""Wrapper for __builtin__.open
|
||||
|
||||
Trick so that open won't become a bound method when stored
|
||||
as a class variable (as dumbdbm does).
|
||||
|
||||
See initstdio() in Python/pythonrun.c.
|
||||
"""
|
||||
def __new__(cls, *args, **kwargs):
|
||||
return open(*args, **kwargs)
|
||||
|
||||
|
||||
class UnsupportedOperation(ValueError, IOError):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue