diff --git a/newsfragments/3340.other b/newsfragments/3340.other new file mode 100644 index 000000000..e69de29bb diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index f9e0f2b01..bf44785a5 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -1,6 +1,6 @@ from __future__ import print_function -import os, signal, sys, time +import os, signal, time from random import randrange from six.moves import StringIO @@ -8,7 +8,6 @@ from twisted.internet import reactor, defer from twisted.python import failure from twisted.trial import unittest -from allmydata.util import fileutil, log from ..util.assertutil import precondition from allmydata.util.encodingutil import (unicode_platform, get_filesystem_encoding, get_io_encoding) @@ -89,39 +88,6 @@ class ReallyEqualMixin(object): self.assertEqual(type(a), type(b), "a :: %r, b :: %r, %r" % (a, b, msg)) -class NonASCIIPathMixin(object): - def mkdir_nonascii(self, dirpath): - # Kludge to work around the fact that buildbot can't remove a directory tree that has - # any non-ASCII directory names on Windows. (#1472) - if sys.platform == "win32": - def _cleanup(): - try: - fileutil.rm_dir(dirpath) - finally: - if os.path.exists(dirpath): - msg = ("We were unable to delete a non-ASCII directory %r created by the test. " - "This is liable to cause failures on future builds." % (dirpath,)) - print(msg) - log.err(msg) - self.addCleanup(_cleanup) - os.mkdir(dirpath) - - def unicode_or_fallback(self, unicode_name, fallback_name, io_as_well=False): - if not unicode_platform(): - try: - unicode_name.encode(get_filesystem_encoding()) - except UnicodeEncodeError: - return fallback_name - - if io_as_well: - try: - unicode_name.encode(get_io_encoding()) - except UnicodeEncodeError: - return fallback_name - - return unicode_name - - class SignalMixin(object): # This class is necessary for any code which wants to use Processes # outside the usual reactor.run() environment. It is copied from diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index 41a44d5a6..b188008fd 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -83,7 +83,7 @@ BASECONFIG_I = ("[client]\n" "introducer.furl = %s\n" ) -class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.TestCase): +class Basic(testutil.ReallyEqualMixin, unittest.TestCase): def test_loadable(self): basedir = "test_client.Basic.test_loadable" os.mkdir(basedir) diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index 162852c38..269a8a356 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -12,7 +12,7 @@ from errno import ENOENT if sys.platform == "win32": from ctypes import WINFUNCTYPE, WinError, windll, POINTER, byref, c_ulonglong, \ create_unicode_buffer, get_last_error - from ctypes.wintypes import BOOL, DWORD, LPCWSTR, LPWSTR, LPVOID, HANDLE + from ctypes.wintypes import BOOL, DWORD, LPCWSTR, LPWSTR, LPVOID from twisted.python import log @@ -538,60 +538,6 @@ def get_available_space(whichdir, reserved_space): return 0 -if sys.platform == "win32": - # - CreateFileW = WINFUNCTYPE( - HANDLE, LPCWSTR, DWORD, DWORD, LPVOID, DWORD, DWORD, HANDLE, - use_last_error=True - )(("CreateFileW", windll.kernel32)) - - GENERIC_WRITE = 0x40000000 - FILE_SHARE_READ = 0x00000001 - FILE_SHARE_WRITE = 0x00000002 - OPEN_EXISTING = 3 - INVALID_HANDLE_VALUE = 0xFFFFFFFF - - # - FlushFileBuffers = WINFUNCTYPE( - BOOL, HANDLE, - use_last_error=True - )(("FlushFileBuffers", windll.kernel32)) - - # - CloseHandle = WINFUNCTYPE( - BOOL, HANDLE, - use_last_error=True - )(("CloseHandle", windll.kernel32)) - - # - def flush_volume(path): - abspath = os.path.realpath(path) - if abspath.startswith("\\\\?\\"): - abspath = abspath[4 :] - drive = os.path.splitdrive(abspath)[0] - - print("flushing %r" % (drive,)) - hVolume = CreateFileW(u"\\\\.\\" + drive, - GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - None, - OPEN_EXISTING, - 0, - None - ) - if hVolume == INVALID_HANDLE_VALUE: - raise WinError(get_last_error()) - - if FlushFileBuffers(hVolume) == 0: - raise WinError(get_last_error()) - - CloseHandle(hVolume) -else: - def flush_volume(path): - # use sync()? - pass - - class ConflictError(Exception): pass diff --git a/src/allmydata/util/rrefutil.py b/src/allmydata/util/rrefutil.py index 0dde651d3..40e921507 100644 --- a/src/allmydata/util/rrefutil.py +++ b/src/allmydata/util/rrefutil.py @@ -1,7 +1,7 @@ from twisted.internet import address -from foolscap.api import Violation, RemoteException, DeadReferenceError, \ - SturdyRef +from foolscap.api import Violation, RemoteException, SturdyRef + def add_version_to_remote_reference(rref, default): """I try to add a .version attribute to the given RemoteReference. I call @@ -19,12 +19,6 @@ def add_version_to_remote_reference(rref, default): d.addCallbacks(_got_version, _no_get_version) return d -def trap_and_discard(f, *errorTypes): - f.trap(*errorTypes) - -def trap_deadref(f): - return trap_and_discard(f, DeadReferenceError) - def connection_hints_for_furl(furl): hints = []