Merge lp:~ralsina/python-oops/py3 into lp:python-oops

Proposed by Roberto Alsina
Status: Work in progress
Proposed branch: lp:~ralsina/python-oops/py3
Merge into: lp:python-oops
Diff against target: 197 lines (+24/-25)
7 files modified
bootstrap.py (+6/-6)
oops/config.py (+3/-3)
oops/createhooks.py (+7/-7)
oops/publishers.py (+1/-1)
oops/tests/test_createhooks.py (+2/-2)
oops/tests/test_publishers.py (+2/-2)
versions.cfg (+3/-4)
To merge this branch: bzr merge lp:~ralsina/python-oops/py3
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+261557@code.launchpad.net

Commit message

Pretty much automatic conversion to python 3, but tests pass...

Description of the change

Pretty much automatic conversion to python 3, but tests pass...

To post a comment you must log in.

Unmerged revisions

38. By Roberto Alsina

py3 version, passes tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bootstrap.py'
2--- bootstrap.py 2011-08-10 05:06:50 +0000
3+++ bootstrap.py 2015-06-09 19:09:00 +0000
4@@ -19,7 +19,7 @@
5 use the -c option to specify an alternate configuration file.
6 """
7
8-import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess
9+import os, shutil, sys, tempfile, textwrap, urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, subprocess
10 from optparse import OptionParser
11
12 if sys.platform == 'win32':
13@@ -51,7 +51,7 @@
14 # We will restart with python -S.
15 args = sys.argv[:]
16 args[0:0] = [sys.executable, '-S']
17- args = map(quote, args)
18+ args = list(map(quote, args))
19 os.execv(sys.executable, args)
20 # Now we are running with -S. We'll get the clean sys.path, import site
21 # because distutils will do it later, and then reset the path and clean
22@@ -60,7 +60,7 @@
23 clean_path = sys.path[:]
24 import site
25 sys.path[:] = clean_path
26-for k, v in sys.modules.items():
27+for k, v in list(sys.modules.items()):
28 if (hasattr(v, '__path__') and
29 len(v.__path__)==1 and
30 not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))):
31@@ -77,7 +77,7 @@
32 if value:
33 if '://' not in value: # It doesn't smell like a URL.
34 value = 'file://%s' % (
35- urllib.pathname2url(
36+ urllib.request.pathname2url(
37 os.path.abspath(os.path.expanduser(value))),)
38 if opt_str == '--download-base' and not value.endswith('/'):
39 # Download base needs a trailing slash to make the world happy.
40@@ -160,10 +160,10 @@
41 if not hasattr(pkg_resources, '_distribute'):
42 raise ImportError
43 except ImportError:
44- ez_code = urllib2.urlopen(
45+ ez_code = urllib.request.urlopen(
46 options.setup_source).read().replace('\r\n', '\n')
47 ez = {}
48- exec ez_code in ez
49+ exec(ez_code, ez)
50 setup_args = dict(to_dir=eggs_dir, download_delay=0)
51 if options.download_base:
52 setup_args['download_base'] = options.download_base
53
54=== modified file 'oops/config.py'
55--- oops/config.py 2012-06-26 20:57:41 +0000
56+++ oops/config.py 2015-06-09 19:09:00 +0000
57@@ -102,8 +102,8 @@
58 from copy import deepcopy
59 import warnings
60
61-from createhooks import default_hooks
62-from publishers import (
63+from .createhooks import default_hooks
64+from .publishers import (
65 convert_result_to_list,
66 publish_to_many,
67 )
68@@ -208,7 +208,7 @@
69 "instead, with an oops.publishers.publish_to_many object "
70 "if multiple publishers are needed",
71 DeprecationWarning, stacklevel=2)
72- old_publishers = map(convert_result_to_list, self.publishers)
73+ old_publishers = list(map(convert_result_to_list, self.publishers))
74 if self.publisher:
75 publisher = publish_to_many(self.publisher, *old_publishers)
76 else:
77
78=== modified file 'oops/createhooks.py'
79--- oops/createhooks.py 2011-11-13 21:24:42 +0000
80+++ oops/createhooks.py 2015-06-09 19:09:00 +0000
81@@ -42,7 +42,7 @@
82 _sentinel = object()
83
84 # (Prep for python3 - should be set conditional on version
85-strtypes = (basestring,)
86+strtypes = (str,)
87
88
89 def _simple_copy(key):
90@@ -67,19 +67,19 @@
91 serialize it, but a representation is needed for the report. It is
92 exposed a convenience for other on_create hook authors.
93 """
94- if isinstance(obj, unicode):
95+ if isinstance(obj, str):
96 return obj
97 # A call to str(obj) could raise anything at all.
98 # We'll ignore these errors, and print something
99 # useful instead, but also log the error.
100 # We disable the pylint warning for the blank except.
101 try:
102- value = unicode(obj)
103+ value = str(obj)
104 except:
105- value = u'<unprintable %s object>' % (
106- unicode(type(obj).__name__))
107+ value = '<unprintable %s object>' % (
108+ str(type(obj).__name__))
109 # Some objects give back bytestrings to __unicode__...
110- if isinstance(value, str):
111+ if isinstance(value, bytes):
112 value = value.decode('latin-1')
113 return value
114
115@@ -110,7 +110,7 @@
116 if isinstance(info[2], strtypes):
117 tb_text = info[2]
118 else:
119- tb_text = u''.join(map(safe_unicode, traceback.format_tb(info[2])))
120+ tb_text = ''.join(map(safe_unicode, traceback.format_tb(info[2])))
121 report['tb_text'] = tb_text
122
123
124
125=== modified file 'oops/publishers.py'
126--- oops/publishers.py 2012-08-10 02:18:06 +0000
127+++ oops/publishers.py 2015-06-09 19:09:00 +0000
128@@ -36,7 +36,7 @@
129 report = dict(report)
130 output = pformat(report)
131 if not report.get('id'):
132- report['id'] = md5(output).hexdigest()
133+ report['id'] = md5(output.encode('utf-8')).hexdigest()
134 output = pformat(report)
135 stream.write(output)
136 stream.write('\n')
137
138=== modified file 'oops/tests/test_createhooks.py'
139--- oops/tests/test_createhooks.py 2011-11-13 21:24:42 +0000
140+++ oops/tests/test_createhooks.py 2015-06-09 19:09:00 +0000
141@@ -51,7 +51,7 @@
142 attach_exc_info(report, {'exc_info':sys.exc_info()})
143 self.assertEqual('ValueError', report['type'])
144 self.assertEqual('foo bar', report['value'])
145- self.assertIsInstance(report['tb_text'], basestring)
146+ self.assertIsInstance(report['tb_text'], str)
147
148 def test_attach_date(self):
149 report = {}
150@@ -78,7 +78,7 @@
151 attach_exc_info(report, {'exc_info':sys.exc_info()})
152 self.assertEqual(
153 '<unprintable UnprintableException object>', report['value'])
154- self.assertIsInstance(report['tb_text'], basestring)
155+ self.assertIsInstance(report['tb_text'], str)
156
157 def test_defaults(self):
158 self.assertEqual([attach_exc_info, attach_date, copy_reporter, copy_topic,
159
160=== modified file 'oops/tests/test_publishers.py'
161--- oops/tests/test_publishers.py 2012-08-10 02:18:06 +0000
162+++ oops/tests/test_publishers.py 2015-06-09 19:09:00 +0000
163@@ -19,7 +19,7 @@
164
165 from hashlib import md5
166 from pprint import pformat
167-from StringIO import StringIO
168+from io import StringIO
169
170 import testtools
171
172@@ -188,7 +188,7 @@
173 publisher = pprint_to_stream(output)
174 published = publisher({'foo': 'bar'})
175 pprint_value = pformat({'foo': 'bar'})
176- self.assertEqual([md5(pprint_value).hexdigest()], published)
177+ self.assertEqual([md5(pprint_value.encode('utf-8')).hexdigest()], published)
178
179 def test_outputs_pprint(self):
180 output = StringIO()
181
182=== modified file 'versions.cfg'
183--- versions.cfg 2011-08-10 06:08:53 +0000
184+++ versions.cfg 2015-06-09 19:09:00 +0000
185@@ -5,9 +5,8 @@
186 fixtures = 0.3.6
187 iso8601 = 0.1.4
188 pytz = 2010o
189-setuptools = 0.6c11
190 testtools = 0.9.11
191 zc.recipe.egg = 1.3.2
192-z3c.recipe.filetemplate = 2.1.0
193-z3c.recipe.scripts = 1.0.1
194-zc.buildout = 1.5.1
195+zc.recipe.filetemplate = 2.1.0
196+zc.recipe.scripts = 1.0.1
197+zc.buildout = 2.3.1

Subscribers

People subscribed via source and target branches

to all changes: