[pypy-svn] r49395 - in pypy/branch/pypy-interp-file: . interpreter interpreter/test module module/_file module/marshal module/sys
arigo at codespeak.net
arigo at codespeak.net
Wed Dec 5 19:19:30 CET 2007
Author: arigo
Date: Wed Dec 5 19:19:29 2007
New Revision: 49395
Added:
pypy/branch/pypy-interp-file/
- copied from r49388, pypy/dist/pypy/
pypy/branch/pypy-interp-file/interpreter/gateway.py
- copied unchanged from r49394, pypy/dist/pypy/interpreter/gateway.py
pypy/branch/pypy-interp-file/interpreter/test/test_gateway.py
- copied unchanged from r49394, pypy/dist/pypy/interpreter/test/test_gateway.py
pypy/branch/pypy-interp-file/module/
- copied from r49393, pypy/dist/pypy/module/
pypy/branch/pypy-interp-file/module/_file/
- copied from r49388, pypy/dist/pypy/module/_file/
pypy/branch/pypy-interp-file/module/_file/interp_stream.py
- copied, changed from r49345, pypy/dist/pypy/module/_file/interp_file.py
Removed:
pypy/branch/pypy-interp-file/module/_file/interp_file.py
Modified:
pypy/branch/pypy-interp-file/interpreter/baseobjspace.py
pypy/branch/pypy-interp-file/interpreter/module.py
pypy/branch/pypy-interp-file/module/_file/__init__.py
pypy/branch/pypy-interp-file/module/_file/app_file.py
pypy/branch/pypy-interp-file/module/marshal/interp_marshal.py
pypy/branch/pypy-interp-file/module/sys/__init__.py
pypy/branch/pypy-interp-file/module/sys/app.py
Log:
Branch in which I'm moving app_file to interpreter-level code.
Modified: pypy/branch/pypy-interp-file/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/pypy-interp-file/interpreter/baseobjspace.py Wed Dec 5 19:19:29 2007
@@ -206,7 +206,7 @@
for w_modname in self.unpackiterable(
self.sys.get('builtin_module_names')):
modname = self.str_w(w_modname)
- mod = self.getbuiltinmodule(modname)
+ mod = self.interpclass_w(self.getbuiltinmodule(modname))
if isinstance(mod, Module):
mod.startup(self)
@@ -214,12 +214,12 @@
w_exitfunc = self.sys.getdictvalue_w(self, 'exitfunc')
if w_exitfunc is not None:
self.call_function(w_exitfunc)
- w_exithandlers = self.sys.getdictvalue_w(self, 'pypy__exithandlers__')
- if w_exithandlers is not None:
- while self.is_true(w_exithandlers):
- w_key_value = self.call_method(w_exithandlers, 'popitem')
- w_key, w_value = self.unpacktuple(w_key_value, 2)
- self.call_function(w_value)
+ for w_modname in self.unpackiterable(
+ self.sys.get('builtin_module_names')):
+ modname = self.str_w(w_modname)
+ mod = self.interpclass_w(self.getbuiltinmodule(modname))
+ if isinstance(mod, Module):
+ mod.shutdown(self)
if self.config.objspace.std.withdictmeasurement:
from pypy.objspace.std.dictmultiobject import report
report()
Modified: pypy/branch/pypy-interp-file/interpreter/module.py
==============================================================================
--- pypy/dist/pypy/interpreter/module.py (original)
+++ pypy/branch/pypy-interp-file/interpreter/module.py Wed Dec 5 19:19:29 2007
@@ -24,6 +24,11 @@
"""This is called at runtime before the space gets uses to allow
the module to do initialization at runtime.
"""
+
+ def shutdown(self, space):
+ """This is called when the space is shut down, just after
+ sys.exitfunc().
+ """
def getdict(self):
return self.w_dict
Modified: pypy/branch/pypy-interp-file/module/_file/__init__.py
==============================================================================
--- pypy/dist/pypy/module/_file/__init__.py (original)
+++ pypy/branch/pypy-interp-file/module/_file/__init__.py Wed Dec 5 19:19:29 2007
@@ -4,11 +4,21 @@
class Module(MixedModule):
appleveldefs = {
- "file": "app_file.file",
}
interpleveldefs = {
- "open_file_as_stream": "interp_file.open_file_as_stream",
- "fdopen_as_stream": "interp_file.fdopen_as_stream",
+ "file": "interp_file.W_File",
}
+ def shutdown(self, space):
+ # at shutdown, flush all open streams
+ from pypy.module._file.interp_file import getopenstreams
+ openstreams = getopenstreams(space)
+ while openstreams:
+ for stream in openstreams.keys():
+ try:
+ del openstreams[stream]
+ except KeyError:
+ pass # key was removed in the meantime
+ else:
+ stream.flush()
Modified: pypy/branch/pypy-interp-file/module/_file/app_file.py
==============================================================================
--- pypy/dist/pypy/module/_file/app_file.py (original)
+++ pypy/branch/pypy-interp-file/module/_file/app_file.py Wed Dec 5 19:19:29 2007
@@ -25,13 +25,13 @@
_closed = True # Until the file is successfully opened
- def __init__(self, name, mode='r', buffering=-1):
+ #def __init__(self, name, mode='r', buffering=-1):
stream = _file.open_file_as_stream(name, mode, buffering)
fd = stream.try_to_find_file_descriptor()
assert fd != -1
self._fdopenstream(fd, mode, buffering, name, stream)
- def fdopen(cls, fd, mode='r', buffering=-1):
+ #def fdopen(cls, fd, mode='r', buffering=-1):
f = cls.__new__(cls)
stream = _file.fdopen_as_stream(fd, mode, buffering)
f._fdopenstream(fd, mode, buffering, '<fdopen>', stream)
@@ -88,7 +88,7 @@
newlines = property(lambda self: self.getnewlines(),
doc = "end-of-line convention used in this file")
- def read(self, n=-1):
+ #def read(self, n=-1):
"""read([size]) -> read at most size bytes, returned as a string.
If the size argument is negative or omitted, read until EOF is reached.
@@ -114,7 +114,7 @@
self.stream.unlock()
return ''.join(result)
- def readline(self, size=-1):
+ #def readline(self, size=-1):
"""readline([size]) -> next line from the file, as a string.
Retain newline. A non-negative size argument limits the maximum
@@ -149,7 +149,7 @@
self.stream.unlock()
return ''.join(result)
- def readlines(self, size=0):
+ #def readlines(self, size=0):
"""readlines([size]) -> list of strings, each a line from the file.
Call readline() repeatedly and return a list of the lines so read.
@@ -177,7 +177,7 @@
self.stream.unlock()
return result
- def write(self, data):
+ #def write(self, data):
"""write(str) -> None. Write string str to file.
Note that due to buffering, flush() or close() may be needed before
@@ -254,7 +254,7 @@
raise ValueError('I/O operation on closed file')
self.stream.flush()
- def close(self):
+ #def close(self):
"""close() -> None or (perhaps) an integer. Close the file.
Sets data attribute .closed to True. A closed file cannot be used for
Modified: pypy/branch/pypy-interp-file/module/marshal/interp_marshal.py
==============================================================================
--- pypy/dist/pypy/module/marshal/interp_marshal.py (original)
+++ pypy/branch/pypy-interp-file/module/marshal/interp_marshal.py Wed Dec 5 19:19:29 2007
@@ -1,7 +1,7 @@
from pypy.interpreter.baseobjspace import ObjSpace
from pypy.interpreter.error import OperationError
from pypy.rlib.rarithmetic import intmask
-from pypy.module._file.interp_file import file2stream
+#from pypy.module._file.interp_file import file2stream
import sys
# Py_MARSHAL_VERSION = 2
Modified: pypy/branch/pypy-interp-file/module/sys/__init__.py
==============================================================================
--- pypy/dist/pypy/module/sys/__init__.py (original)
+++ pypy/branch/pypy-interp-file/module/sys/__init__.py Wed Dec 5 19:19:29 2007
@@ -76,7 +76,6 @@
'__excepthook__' : 'app.excepthook',
'exit' : 'app.exit',
'exitfunc' : 'app.exitfunc',
- 'pypy__exithandlers__' : 'app.pypy__exithandlers__', # internal
'getfilesystemencoding' : 'app.getfilesystemencoding',
'callstats' : 'app.callstats',
}
Modified: pypy/branch/pypy-interp-file/module/sys/app.py
==============================================================================
--- pypy/dist/pypy/module/sys/app.py (original)
+++ pypy/branch/pypy-interp-file/module/sys/app.py Wed Dec 5 19:19:29 2007
@@ -24,8 +24,6 @@
def exitfunc():
"""Placeholder for sys.exitfunc(), which is called when PyPy exits."""
-pypy__exithandlers__ = {}
-
#import __builtin__
def getfilesystemencoding():
More information about the pypy-svn
mailing list