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