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):
if closed:
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(object):
class StringIO:
"""class StringIO([buffer])
When a StringIO object is created, it can be initialized to an existing
......
......@@ -80,9 +80,8 @@ class IterableUserDict(UserDict):
def __iter__(self):
return iter(self.data)
# Pyston change: disable using the _abcoll module for now.
# import _abcoll
# _abcoll.MutableMapping.register(IterableUserDict)
import _abcoll
_abcoll.MutableMapping.register(IterableUserDict)
class DictMixin:
......
......@@ -69,9 +69,7 @@ class excel_tab(excel):
delimiter = '\t'
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(object):
class DictReader:
def __init__(self, f, fieldnames=None, restkey=None, restval=None,
dialect="excel", *args, **kwds):
self._fieldnames = fieldnames # list of keys for the dict
......
......@@ -22,11 +22,8 @@ class BoundaryError(MessageParseError):
"""Couldn't find terminating boundary."""
# Pyston change: we don't support multiple inheritance yet, so this error class is tricky.
# We could make it so that it only inherits one of the base classes, but I'd rather that
# 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 MultipartConversionError(MessageError, TypeError):
"""Conversion to a multipart is prohibited."""
class CharsetError(MessageError):
......
......@@ -43,9 +43,7 @@ _norm_encoding_map = (' . '
' ')
_aliases = aliases.aliases
# Pyston change: we don't support multiple inheritance yet
#class CodecRegistryError(LookupError, SystemError):
class CodecRegistryError(LookupError):
class CodecRegistryError(LookupError, SystemError):
pass
def normalize_encoding(encoding):
......
......@@ -29,8 +29,7 @@ __all__ = [
# Imports.
# Pyston change: don't import io
# import io as _io
import io as _io
import os as _os
import errno as _errno
from random import Random as _Random
......@@ -198,10 +197,8 @@ def _get_default_tempdir():
fd = _os.open(filename, flags, 0o600)
try:
try:
# Pyston change: simplify this so that it doesn't need the _io module:
_os.write(fd, b'blat')
# with _io.open(fd, 'wb', closefd=False) as fp:
# fp.write(b'blat')
with _io.open(fd, 'wb', closefd=False) as fp:
fp.write(b'blat')
finally:
_os.close(fd)
finally:
......
......@@ -33,8 +33,7 @@ try:
except NameError:
StringTypes = (StringType,)
# Pyston change: 'buffer' is not implemented yet
# BufferType = buffer
BufferType = buffer
TupleType = tuple
ListType = list
......
......@@ -1599,7 +1599,7 @@ extern "C" PyObject* PyMethod_Class(PyObject* im) noexcept {
void setupClassobj() {
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),
offsetof(BoxedInstance, weakreflist), sizeof(BoxedInstance), false, "instance");
......
......@@ -46,6 +46,8 @@ public:
BoxedTuple* bases;
BoxedString* name;
Box** weakreflist;
BoxedClassobj(BoxedString* name, BoxedTuple* bases) : bases(bases), name(name) {}
static void gcHandler(GCVisitor* v, Box* _o) {
......
......@@ -48,6 +48,9 @@ test_wr(frozenset())
test_wr((i*i for i in range(1000000)))
test_wr(set)
test_wr(file("/etc/passwd"))
class Old:
pass
test_wr(Old)
# missing: db cursor from the bsddb module
# missing: sockets
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