Merge lp:~cjwatson/lazr.restful/py3-builtins into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 262
Proposed branch: lp:~cjwatson/lazr.restful/py3-builtins
Merge into: lp:lazr.restful
Diff against target: 53 lines (+10/-4)
3 files modified
src/lazr/restful/debug.py (+1/-1)
src/lazr/restful/docs/webservice-declarations.rst (+4/-2)
src/lazr/restful/tests/test_docs.py (+5/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-builtins
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+390181@code.launchpad.net

Commit message

Handle renaming of __builtin__ to builtins in Python 3.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/debug.py'
2--- src/lazr/restful/debug.py 2020-02-04 11:52:59 +0000
3+++ src/lazr/restful/debug.py 2020-09-02 15:47:29 +0000
4@@ -20,7 +20,7 @@
5 def typename(obj):
6 """Return the typename of an object."""
7 t = type(obj)
8- if t.__module__ == '__builtin__':
9+ if t.__module__ in {'__builtin__', 'builtins'}:
10 return t.__name__
11 else:
12 return "%s.%s" % (t.__module__, t.__name__)
13
14=== modified file 'src/lazr/restful/docs/webservice-declarations.rst'
15--- src/lazr/restful/docs/webservice-declarations.rst 2020-08-21 16:16:09 +0000
16+++ src/lazr/restful/docs/webservice-declarations.rst 2020-09-02 15:47:29 +0000
17@@ -891,8 +891,10 @@
18 The created interface is named with 'Entry' appended to the original
19 name, and is in the same module
20
21- >>> entry_interface.__module__
22- '__builtin__'
23+ >>> import sys
24+ >>> entry_interface.__module__ == (
25+ ... 'builtins' if sys.version_info[0] >= 3 else '__builtin__')
26+ True
27 >>> entry_interface.__name__
28 'IBookEntry_beta'
29
30
31=== modified file 'src/lazr/restful/tests/test_docs.py'
32--- src/lazr/restful/tests/test_docs.py 2020-08-21 16:16:09 +0000
33+++ src/lazr/restful/tests/test_docs.py 2020-09-02 15:47:29 +0000
34@@ -25,6 +25,8 @@
35 import atexit
36 import doctest
37 import os
38+import re
39+
40 from pkg_resources import (
41 resource_filename, resource_exists, resource_listdir, cleanup_resources)
42 from zope.testing import renormalizing
43@@ -37,7 +39,9 @@
44 doctest.REPORT_NDIFF)
45
46
47-checker = renormalizing.OutputChecker()
48+checker = renormalizing.OutputChecker([
49+ (re.compile(r'__builtin__\.'), 'builtins.'),
50+ ])
51
52
53 def tearDown(test):

Subscribers

People subscribed via source and target branches