Commit 3f259086 authored by Marius Wachtler's avatar Marius Wachtler

remove old workarounds + allow weakref of old style classes

parent 40c4e710
...@@ -39,9 +39,7 @@ def _complain_ifclosed(closed): ...@@ -39,9 +39,7 @@ def _complain_ifclosed(closed):
if closed: if closed:
raise ValueError, "I/O operation on closed file" raise ValueError, "I/O operation on closed file"
# Pyston change: make this a new style class, looks like we don't support iterating otherwise class StringIO:
# class StringIO:
class StringIO(object):
"""class StringIO([buffer]) """class StringIO([buffer])
When a StringIO object is created, it can be initialized to an existing When a StringIO object is created, it can be initialized to an existing
......
...@@ -80,9 +80,8 @@ class IterableUserDict(UserDict): ...@@ -80,9 +80,8 @@ class IterableUserDict(UserDict):
def __iter__(self): def __iter__(self):
return iter(self.data) return iter(self.data)
# Pyston change: disable using the _abcoll module for now. import _abcoll
# import _abcoll _abcoll.MutableMapping.register(IterableUserDict)
# _abcoll.MutableMapping.register(IterableUserDict)
class DictMixin: class DictMixin:
......
...@@ -69,9 +69,7 @@ class excel_tab(excel): ...@@ -69,9 +69,7 @@ class excel_tab(excel):
delimiter = '\t' delimiter = '\t'
register_dialect("excel-tab", excel_tab) register_dialect("excel-tab", excel_tab)
# Pyston change: make this a new style class, looks like we don't support iterating otherwise class DictReader:
# class DictReader:
class DictReader(object):
def __init__(self, f, fieldnames=None, restkey=None, restval=None, def __init__(self, f, fieldnames=None, restkey=None, restval=None,
dialect="excel", *args, **kwds): dialect="excel", *args, **kwds):
self._fieldnames = fieldnames # list of keys for the dict self._fieldnames = fieldnames # list of keys for the dict
......
...@@ -22,11 +22,8 @@ class BoundaryError(MessageParseError): ...@@ -22,11 +22,8 @@ class BoundaryError(MessageParseError):
"""Couldn't find terminating boundary.""" """Couldn't find terminating boundary."""
# Pyston change: we don't support multiple inheritance yet, so this error class is tricky. class MultipartConversionError(MessageError, TypeError):
# We could make it so that it only inherits one of the base classes, but I'd rather that """Conversion to a multipart is prohibited."""
# anyone who tries to use this error gets a loud error message rather than different behavior.
# class MultipartConversionError(MessageError, TypeError):
# """Conversion to a multipart is prohibited."""
class CharsetError(MessageError): class CharsetError(MessageError):
......
...@@ -43,9 +43,7 @@ _norm_encoding_map = (' . ' ...@@ -43,9 +43,7 @@ _norm_encoding_map = (' . '
' ') ' ')
_aliases = aliases.aliases _aliases = aliases.aliases
# Pyston change: we don't support multiple inheritance yet class CodecRegistryError(LookupError, SystemError):
#class CodecRegistryError(LookupError, SystemError):
class CodecRegistryError(LookupError):
pass pass
def normalize_encoding(encoding): def normalize_encoding(encoding):
......
...@@ -29,8 +29,7 @@ __all__ = [ ...@@ -29,8 +29,7 @@ __all__ = [
# Imports. # Imports.
# Pyston change: don't import io import io as _io
# import io as _io
import os as _os import os as _os
import errno as _errno import errno as _errno
from random import Random as _Random from random import Random as _Random
...@@ -198,10 +197,8 @@ def _get_default_tempdir(): ...@@ -198,10 +197,8 @@ def _get_default_tempdir():
fd = _os.open(filename, flags, 0o600) fd = _os.open(filename, flags, 0o600)
try: try:
try: try:
# Pyston change: simplify this so that it doesn't need the _io module: with _io.open(fd, 'wb', closefd=False) as fp:
_os.write(fd, b'blat') fp.write(b'blat')
# with _io.open(fd, 'wb', closefd=False) as fp:
# fp.write(b'blat')
finally: finally:
_os.close(fd) _os.close(fd)
finally: finally:
......
...@@ -33,8 +33,7 @@ try: ...@@ -33,8 +33,7 @@ try:
except NameError: except NameError:
StringTypes = (StringType,) StringTypes = (StringType,)
# Pyston change: 'buffer' is not implemented yet BufferType = buffer
# BufferType = buffer
TupleType = tuple TupleType = tuple
ListType = list ListType = list
......
...@@ -1599,7 +1599,7 @@ extern "C" PyObject* PyMethod_Class(PyObject* im) noexcept { ...@@ -1599,7 +1599,7 @@ extern "C" PyObject* PyMethod_Class(PyObject* im) noexcept {
void setupClassobj() { void setupClassobj() {
classobj_cls = BoxedClass::create(type_cls, object_cls, &BoxedClassobj::gcHandler, offsetof(BoxedClassobj, attrs), classobj_cls = BoxedClass::create(type_cls, object_cls, &BoxedClassobj::gcHandler, offsetof(BoxedClassobj, attrs),
0, sizeof(BoxedClassobj), false, "classobj"); offsetof(BoxedClassobj, weakreflist), sizeof(BoxedClassobj), false, "classobj");
instance_cls = BoxedClass::create(type_cls, object_cls, &BoxedInstance::gcHandler, offsetof(BoxedInstance, attrs), instance_cls = BoxedClass::create(type_cls, object_cls, &BoxedInstance::gcHandler, offsetof(BoxedInstance, attrs),
offsetof(BoxedInstance, weakreflist), sizeof(BoxedInstance), false, "instance"); offsetof(BoxedInstance, weakreflist), sizeof(BoxedInstance), false, "instance");
......
...@@ -46,6 +46,8 @@ public: ...@@ -46,6 +46,8 @@ public:
BoxedTuple* bases; BoxedTuple* bases;
BoxedString* name; BoxedString* name;
Box** weakreflist;
BoxedClassobj(BoxedString* name, BoxedTuple* bases) : bases(bases), name(name) {} BoxedClassobj(BoxedString* name, BoxedTuple* bases) : bases(bases), name(name) {}
static void gcHandler(GCVisitor* v, Box* _o) { static void gcHandler(GCVisitor* v, Box* _o) {
......
...@@ -48,6 +48,9 @@ test_wr(frozenset()) ...@@ -48,6 +48,9 @@ test_wr(frozenset())
test_wr((i*i for i in range(1000000))) test_wr((i*i for i in range(1000000)))
test_wr(set) test_wr(set)
test_wr(file("/etc/passwd")) test_wr(file("/etc/passwd"))
class Old:
pass
test_wr(Old)
# missing: db cursor from the bsddb module # missing: db cursor from the bsddb module
# missing: sockets # missing: sockets
test_wr(array.array('d', [1.0, 2.0, 3.14])) test_wr(array.array('d', [1.0, 2.0, 3.14]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment