##// END OF EJS Templates
py3: trivial renaming of unicode to str
Mads Kiilerich -
r8081:620c13a3 default
parent child Browse files
Show More
@@ -226,12 +226,12 b' class JSONRPCController(TGController):'
226 226 if isinstance(raw_response, HTTPError):
227 227 self._error = str(raw_response)
228 228 except JSONRPCError as e:
229 self._error = unicode(e)
229 self._error = str(e)
230 230 except Exception as e:
231 231 log.error('Encountered unhandled exception: %s',
232 232 traceback.format_exc(),)
233 233 json_exc = JSONRPCError('Internal server error')
234 self._error = unicode(json_exc)
234 self._error = str(json_exc)
235 235
236 236 if self._error is not None:
237 237 raw_response = None
@@ -95,7 +95,7 b' def __get_lockkey(func, *fargs, **fkwarg'
95 95 func_name = str(func.__name__) if hasattr(func, '__name__') else str(func)
96 96
97 97 lockkey = 'task_%s.lock' % \
98 md5(safe_bytes(func_name + '-' + '-'.join(unicode(x) for x in params))).hexdigest()
98 md5(safe_bytes(func_name + '-' + '-'.join(str(x) for x in params))).hexdigest()
99 99 return lockkey
100 100
101 101
@@ -460,11 +460,11 b' def flash(message, category, logf=None):'
460 460 assert category in ('error', 'success', 'warning'), category
461 461 if hasattr(message, '__html__'):
462 462 # render to HTML for storing in cookie
463 safe_message = unicode(message)
463 safe_message = str(message)
464 464 else:
465 465 # Apply str - the message might be an exception with __str__
466 466 # Escape, so we can trust the result without further escaping, without any risk of injection
467 safe_message = html_escape(unicode(message))
467 safe_message = html_escape(str(message))
468 468 if logf is None:
469 469 logf = log.info
470 470 if category == 'success':
@@ -26,7 +26,7 b' def submit(g_recaptcha_response, private'
26 26 return RecaptchaResponse(is_valid=False, error_code='incorrect-captcha-sol')
27 27
28 28 def encode_if_necessary(s):
29 if isinstance(s, unicode):
29 if isinstance(s, str):
30 30 return s.encode('utf-8')
31 31 return s
32 32
@@ -179,8 +179,8 b' def age(prevdate, show_short_version=Fal'
179 179
180 180 :param prevdate: datetime object
181 181 :param show_short_version: if it should approximate the date and return a shorter string
182 :rtype: unicode
183 :returns: unicode words describing age
182 :rtype: str
183 :returns: str words describing age
184 184 """
185 185 now = now or datetime.datetime.now()
186 186 order = ['year', 'month', 'day', 'hour', 'minute', 'second']
@@ -278,7 +278,7 b' def uri_filter(uri):'
278 278 Removes user:password from given url string
279 279
280 280 :param uri:
281 :rtype: unicode
281 :rtype: str
282 282 :returns: filtered list of strings
283 283 """
284 284 if not uri:
@@ -342,10 +342,10 b' class BaseChangeset(object):'
342 342 combined list of ``Node`` objects
343 343
344 344 ``author``
345 author of the changeset, as unicode
345 author of the changeset, as str
346 346
347 347 ``message``
348 message of the changeset, as unicode
348 message of the changeset, as str
349 349
350 350 ``parents``
351 351 list of parent changesets
@@ -428,7 +428,7 b' class MercurialRepository(BaseRepository'
428 428
429 429 if revision in [-1, None]:
430 430 revision = b'tip'
431 elif isinstance(revision, unicode):
431 elif isinstance(revision, str):
432 432 revision = safe_bytes(revision)
433 433
434 434 try:
@@ -286,7 +286,7 b' class SubprocessIOChunker(object):'
286 286
287 287 - We are multithreaded. Writing in and reading out, err are all sep threads.
288 288 - We support concurrent (in and out) stream processing.
289 - The output is not a stream. It's a queue of read string (bytes, not unicode)
289 - The output is not a stream. It's a queue of read string (bytes, not str)
290 290 chunks. The object behaves as an iterable. You can "for chunk in obj:" us.
291 291 - We are non-blocking in more respects than communicate()
292 292 (reading from subprocess out pauses when internal buffer is full, but
@@ -205,7 +205,7 b' class Setting(Base, BaseDbModel):'
205 205
206 206 @validates('_app_settings_value')
207 207 def validate_settings_value(self, key, val):
208 assert isinstance(val, unicode)
208 assert isinstance(val, str)
209 209 return val
210 210
211 211 @hybrid_property
@@ -125,7 +125,7 b' class GistModel(object):'
125 125 Session().flush() # make database assign gist.gist_id
126 126 if gist_type == Gist.GIST_PUBLIC:
127 127 # use DB ID for easy to use GIST ID
128 gist.gist_access_id = unicode(gist.gist_id)
128 gist.gist_access_id = str(gist.gist_id)
129 129
130 130 log.debug('Creating new %s GIST repo %s', gist_type, gist.gist_access_id)
131 131 repo = RepoModel()._create_filesystem_repo(
@@ -184,7 +184,7 b' class EmailNotificationModel(object):'
184 184 bracket_tags = []
185 185 status_change = kwargs.get('status_change')
186 186 if status_change:
187 bracket_tags.append(unicode(status_change)) # apply unicode to evaluate LazyString before .join
187 bracket_tags.append(str(status_change)) # apply str to evaluate LazyString before .join
188 188 if kwargs.get('closing_pr'):
189 189 bracket_tags.append(_('Closing'))
190 190 if bracket_tags:
@@ -588,13 +588,13 b' class TestGitChangeset(object):'
588 588 'vcs/nodes.py']
589 589 assert set(changed) == set([f.path for f in chset.changed])
590 590
591 def test_commit_message_is_unicode(self):
591 def test_commit_message_is_str(self):
592 592 for cs in self.repo:
593 assert isinstance(cs.message, unicode)
593 assert isinstance(cs.message, str)
594 594
595 def test_changeset_author_is_unicode(self):
595 def test_changeset_author_is_str(self):
596 596 for cs in self.repo:
597 assert isinstance(cs.author, unicode)
597 assert isinstance(cs.author, str)
598 598
599 599 def test_repo_files_content_is_bytes(self):
600 600 changeset = self.repo.get_changeset()
@@ -535,13 +535,13 b' class TestMercurialChangeset(object):'
535 535 # but it would be one of ``removed`` (changeset's attribute)
536 536 assert path in [rf.path for rf in chset.removed]
537 537
538 def test_commit_message_is_unicode(self):
538 def test_commit_message_is_str(self):
539 539 for cm in self.repo:
540 assert isinstance(cm.message, unicode)
540 assert isinstance(cm.message, str)
541 541
542 def test_changeset_author_is_unicode(self):
542 def test_changeset_author_is_str(self):
543 543 for cm in self.repo:
544 assert isinstance(cm.author, unicode)
544 assert isinstance(cm.author, str)
545 545
546 546 def test_repo_files_content_is_bytes(self):
547 547 test_changeset = self.repo.get_changeset(100)
@@ -37,7 +37,7 b' class InMemoryChangesetTestMixin(_Backen'
37 37 for node in to_add:
38 38 self.imc.add(node)
39 39 message = u'Added: %s' % ', '.join((node.path for node in self.nodes))
40 author = unicode(self.__class__)
40 author = str(self.__class__)
41 41 changeset = self.imc.commit(message=message, author=author)
42 42
43 43 newtip = self.repo.get_changeset()
@@ -59,7 +59,7 b' class InMemoryChangesetTestMixin(_Backen'
59 59 for node in self.nodes]
60 60 self.imc.add(*to_add)
61 61 message = u'Added: %s' % ', '.join((node.path for node in self.nodes))
62 author = unicode(self.__class__)
62 author = str(self.__class__)
63 63 changeset = self.imc.commit(message=message, author=author)
64 64
65 65 newtip = self.repo.get_changeset()
@@ -109,7 +109,7 b' class InMemoryChangesetTestMixin(_Backen'
109 109 for node in to_add:
110 110 self.imc.add(node)
111 111 message = u'Added: %s' % ', '.join((node.path for node in self.nodes))
112 author = unicode(self.__class__)
112 author = str(self.__class__)
113 113 changeset = self.imc.commit(message=message, author=author)
114 114
115 115 newtip = self.repo.get_changeset()
@@ -134,7 +134,7 b' class InMemoryChangesetTestMixin(_Backen'
134 134 def test_check_integrity_raise_already_exist(self):
135 135 node = FileNode('foobar', content='baz')
136 136 self.imc.add(node)
137 self.imc.commit(message=u'Added foobar', author=unicode(self))
137 self.imc.commit(message=u'Added foobar', author=str(self))
138 138 self.imc.add(node)
139 139 with pytest.raises(NodeAlreadyExistsError):
140 140 self.imc.commit(message='new message',
@@ -189,7 +189,7 b' class InMemoryChangesetTestMixin(_Backen'
189 189 def test_check_integrity_change_raise_node_does_not_exist(self):
190 190 node = FileNode('foobar', content='baz')
191 191 self.imc.add(node)
192 self.imc.commit(message=u'Added foobar', author=unicode(self))
192 self.imc.commit(message=u'Added foobar', author=str(self))
193 193 node = FileNode('not-foobar', content='')
194 194 self.imc.change(node)
195 195 with pytest.raises(NodeDoesNotExistError):
@@ -198,7 +198,7 b' class InMemoryChangesetTestMixin(_Backen'
198 198 def test_change_raise_node_already_changed(self):
199 199 node = FileNode('foobar', content='baz')
200 200 self.imc.add(node)
201 self.imc.commit(message=u'Added foobar', author=unicode(self))
201 self.imc.commit(message=u'Added foobar', author=str(self))
202 202 node = FileNode('foobar', content='more baz')
203 203 self.imc.change(node)
204 204 with pytest.raises(NodeAlreadyChangedError):
@@ -212,13 +212,13 b' class InMemoryChangesetTestMixin(_Backen'
212 212 with pytest.raises(NodeNotChangedError):
213 213 self.imc.commit(
214 214 message=u'Trying to mark node as changed without touching it',
215 author=unicode(self)
215 author=str(self),
216 216 )
217 217
218 218 def test_change_raise_node_already_removed(self):
219 219 node = FileNode('foobar', content='baz')
220 220 self.imc.add(node)
221 self.imc.commit(message=u'Added foobar', author=unicode(self))
221 self.imc.commit(message=u'Added foobar', author=str(self))
222 222 self.imc.remove(FileNode('foobar'))
223 223 with pytest.raises(NodeAlreadyRemovedError):
224 224 self.imc.change(node)
@@ -230,7 +230,7 b' class InMemoryChangesetTestMixin(_Backen'
230 230 node = self.nodes[0]
231 231 assert node.content == tip.get_node(node.path).content
232 232 self.imc.remove(node)
233 self.imc.commit(message=u'Removed %s' % node.path, author=unicode(self))
233 self.imc.commit(message=u'Removed %s' % node.path, author=str(self))
234 234
235 235 newtip = self.repo.get_changeset()
236 236 assert tip != newtip
@@ -253,7 +253,7 b' class InMemoryChangesetTestMixin(_Backen'
253 253 with pytest.raises(NodeDoesNotExistError):
254 254 self.imc.commit(
255 255 message='Trying to remove node at empty repository',
256 author=str(self)
256 author=str(self),
257 257 )
258 258
259 259 def test_check_integrity_remove_raise_node_does_not_exist(self):
@@ -264,7 +264,7 b' class InMemoryChangesetTestMixin(_Backen'
264 264 with pytest.raises(NodeDoesNotExistError):
265 265 self.imc.commit(
266 266 message=u'Trying to remove not existing node',
267 author=unicode(self)
267 author=str(self),
268 268 )
269 269
270 270 def test_remove_raise_node_already_removed(self):
General Comments 0
You need to be logged in to leave comments. Login now