Changeset 362c121 in trunk
- Timestamp:
- 2020-09-30T15:47:02Z (4 years ago)
- Branches:
- master
- Children:
- dc203e2
- Parents:
- 8f7cafc
- git-author:
- Ross Patterson <me@…> (2020-09-27 20:00:19)
- git-committer:
- Ross Patterson <me@…> (2020-09-30 15:47:02)
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified Makefile ¶
r8f7cafc r362c121 258 258 .tox/make-test-py3-all.diff: .tox/make-test-py3-all-new.log 259 259 (diff -u "$(<:%-new.log=%-old.log)" "$(<)" || true) | tee "$(@)" 260 261 # Locate modules that are candidates for naively converting `unicode` -> `str`. 262 # List all Python source files that reference `unicode` but don't reference `str` 263 .tox/py3-unicode-no-str.ls: 264 find src -type f -iname '*.py' -exec grep -l -E '\Wunicode\W' '{}' ';' | \ 265 xargs grep -L '\Wstr\W' | xargs ls -ld | tee "$(@)" -
TabularUnified src/allmydata/scripts/common.py ¶
r8f7cafc r362c121 3 3 import os, sys, urllib, textwrap 4 4 import codecs 5 from os.path import join 6 7 # BBB: Python 2 compatibility 8 from builtins import str 5 9 from six.moves.configparser import NoSectionError 6 from os.path import join 10 7 11 from twisted.python import usage 12 8 13 from allmydata.util.assertutil import precondition 9 14 from allmydata.util.encodingutil import unicode_to_url, quote_output, \ … … 189 194 raised. 190 195 """ 191 precondition(isinstance(path_unicode, unicode), path_unicode)196 precondition(isinstance(path_unicode, str), path_unicode) 192 197 193 198 from allmydata import uri -
TabularUnified src/allmydata/scripts/stats_gatherer.py ¶
r8f7cafc r362c121 2 2 3 3 import os 4 5 # BBB: Python 2 compatibility 6 from builtins import str 7 4 8 from twisted.python import usage 9 5 10 from allmydata.scripts.common import NoDefaultBasedirOptions 6 11 from allmydata.scripts.create_node import write_tac … … 63 68 basedir = config['basedir'] 64 69 # This should always be called with an absolute Unicode basedir. 65 precondition(isinstance(basedir, unicode), basedir)70 precondition(isinstance(basedir, str), basedir) 66 71 67 72 if os.path.exists(basedir): -
TabularUnified src/allmydata/scripts/tahoe_check.py ¶
r8f7cafc r362c121 3 3 import urllib 4 4 import json 5 6 # BBB: Python 2 compatibility 7 from builtins import str 8 5 9 from twisted.protocols.basic import LineOnlyReceiver 10 6 11 from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ 7 12 UnknownAliasError … … 102 107 def check(options): 103 108 if len(options.locations) == 0: 104 errno = check_location(options, unicode())109 errno = check_location(options, str()) 105 110 if errno != 0: 106 111 return errno … … 326 331 def run(self, options): 327 332 if len(options.locations) == 0: 328 errno = self.deepcheck_location(options, unicode())333 errno = self.deepcheck_location(options, str()) 329 334 if errno != 0: 330 335 return errno -
TabularUnified src/allmydata/stats.py ¶
r8f7cafc r362c121 1 1 from __future__ import print_function 2 3 from past.builtins import unicode4 2 5 3 import json … … 8 6 import time 9 7 from collections import deque 8 9 # BBB: Python 2 compatibility 10 from builtins import str 10 11 11 12 from twisted.internet import reactor … … 158 159 159 160 def count(self, name, delta=1): 160 if isinstance(name, unicode):161 if isinstance(name, str): 161 162 name = name.encode("utf-8") 162 163 val = self.counters.setdefault(name, 0) … … 179 180 result = {} 180 181 for (k, v) in d.items(): 181 if isinstance(k, unicode):182 if isinstance(k, str): 182 183 k = k.encode("utf-8") 183 184 result[k] = v -
TabularUnified src/allmydata/test/check_load.py ¶
r8f7cafc r362c121 37 37 import os, sys, httplib, binascii 38 38 import urllib, json, random, time, urlparse 39 40 # BBB: Python 2 compatibility 41 from builtins import str 39 42 40 43 if sys.argv[1] == "--stats": … … 117 120 global directories_read 118 121 directories_read += 1 119 children = dict( [( unicode(name),value)122 children = dict( [(str(name),value) 120 123 for (name,value) 121 124 in d["children"].iteritems()] ) -
TabularUnified src/allmydata/test/check_memory.py ¶
r8f7cafc r362c121 2 2 3 3 import os, shutil, sys, urllib, time, stat, urlparse 4 5 # BBB: Python 2 compatibility 6 from builtins import str 4 7 from six.moves import cStringIO as StringIO 8 5 9 from twisted.internet import defer, reactor, protocol, error 6 10 from twisted.application import service, internet 7 11 from twisted.web import client as tw_client 12 from twisted.python import log, procutils 13 from foolscap.api import Tub, fireEventually, flushEventualQueue 14 8 15 from allmydata import client, introducer 9 16 from allmydata.immutable import upload … … 12 19 from allmydata.util.fileutil import abspath_expanduser_unicode 13 20 from allmydata.util.encodingutil import get_filesystem_encoding 14 from foolscap.api import Tub, fireEventually, flushEventualQueue15 from twisted.python import log, procutils16 21 17 22 class StallableHTTPGetterDiscarder(tw_client.HTTPPageGetter, object): … … 70 75 71 76 def __init__(self, basedir, mode): 72 self.basedir = basedir = abspath_expanduser_unicode( unicode(basedir))77 self.basedir = basedir = abspath_expanduser_unicode(str(basedir)) 73 78 if not (basedir + os.path.sep).startswith(abspath_expanduser_unicode(u".") + os.path.sep): 74 79 raise AssertionError("safety issue: basedir must be a subdir") -
TabularUnified src/allmydata/test/eliotutil.py ¶
r8f7cafc r362c121 3 3 """ 4 4 5 from past.builtins import unicode 5 # BBB: Python 2 compatibility 6 # Can't use `builtins.str` because it's not JSON encodable: 7 # `exceptions.TypeError: <class 'future.types.newstr.newstr'> is not JSON-encodeable` 8 from past.builtins import unicode as str 6 9 7 10 __all__ = [ … … 30 33 _NAME = Field.for_types( 31 34 u"name", 32 [ unicode],35 [str], 33 36 u"The name of the test.", 34 37 ) -
TabularUnified src/allmydata/test/mutable/test_version.py ¶
r8f7cafc r362c121 2 2 3 3 import os 4 5 # BBB: Python 2 compatibility 6 from builtins import str 4 7 from six.moves import cStringIO as StringIO 8 5 9 from twisted.internet import defer 6 10 from twisted.trial import unittest 11 7 12 from allmydata import uri 8 13 from allmydata.interfaces import SDMF_VERSION, MDMF_VERSION … … 76 81 storage_index = base32.b2a(n.get_storage_index()) 77 82 fso.si_s = storage_index 78 fso.nodedirs = [os.path.dirname(abspath_expanduser_unicode( unicode(storedir)))83 fso.nodedirs = [os.path.dirname(abspath_expanduser_unicode(str(storedir))) 79 84 for (i,ss,storedir) 80 85 in self.iterate_servers()] -
TabularUnified src/allmydata/test/test_auth.py ¶
r8f7cafc r362c121 1 # BBB: Python 2 compatibility 2 from builtins import str 3 1 4 from twisted.trial import unittest 2 5 from twisted.python import filepath … … 40 43 self.account_file = filepath.FilePath(self.mktemp()) 41 44 self.account_file.setContent(DUMMY_ACCOUNTS) 42 abspath = abspath_expanduser_unicode( unicode(self.account_file.path))45 abspath = abspath_expanduser_unicode(str(self.account_file.path)) 43 46 self.checker = auth.AccountFileChecker(None, abspath) 44 47 -
TabularUnified src/allmydata/test/test_deepcheck.py ¶
r8f7cafc r362c121 1 import os, json, urllib 2 3 # BBB: Python 2 compatibility 4 # Can't use `builtins.str` because something deep in Twisted callbacks ends up repr'ing 5 # a `future.types.newstr.newstr` as a *Python 3* byte string representation under 6 # *Python 2*: 7 # File "/home/rpatterson/src/work/sfu/tahoe-lafs/.tox/py27/lib/python2.7/site-packages/allmydata/util/netstring.py", line 43, in split_netstring 8 # assert data[position] == b","[0], position 9 # exceptions.AssertionError: 15 10 # ... 11 # (Pdb) pp data 12 # '334:12:b\'mutable-good\',90:URI:SSK-RO:... 13 from past.builtins import unicode as str 1 14 from future.utils import native_str 2 15 3 import os, json, urllib4 16 from twisted.trial import unittest 5 17 from twisted.internet import defer 6 18 from twisted.internet.defer import inlineCallbacks, returnValue 19 7 20 from allmydata.immutable import upload 8 21 from allmydata.mutable.common import UnrecoverableFileError … … 918 931 mutable_uploadable = MutableData("mutable file contents") 919 932 d = self.g.clients[0].create_mutable_file(mutable_uploadable) 920 d.addCallback(lambda n: self.root.set_node( unicode(name), n))933 d.addCallback(lambda n: self.root.set_node(str(name), n)) 921 934 elif nodetype == "large": 922 935 large = upload.Data("Lots of data\n" * 1000 + name + "\n", None) 923 d = self.root.add_file( unicode(name), large)936 d = self.root.add_file(str(name), large) 924 937 elif nodetype == "small": 925 938 small = upload.Data("Small enough for a LIT", None) 926 d = self.root.add_file( unicode(name), small)939 d = self.root.add_file(str(name), small) 927 940 928 941 d.addCallback(self._stash_node, name)
Note: See TracChangeset
for help on using the changeset viewer.