← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-security-proxied-types into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-security-proxied-types into launchpad:master.

Commit message:
Adjust is_security_proxied_or_harmless for Python 3 types

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/386918
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-security-proxied-types into launchpad:master.
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 87ca1bc..5ce822e 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -38,7 +38,7 @@ import os
 from StringIO import StringIO
 import sys
 from textwrap import dedent
-from types import InstanceType
+import types
 import uuid
 import warnings
 
@@ -5105,16 +5105,18 @@ class BareLaunchpadObjectFactory(ObjectFactory):
 # Some factory methods return simple Python types. We don't add
 # security wrappers for them, as well as for objects created by
 # other Python libraries.
-unwrapped_types = frozenset((
-        BaseRecipeBranch,
-        DSCFile,
-        InstanceType,
-        Message,
-        datetime,
-        int,
-        str,
-        unicode,
-        ))
+unwrapped_types = {
+    BaseRecipeBranch,
+    DSCFile,
+    Message,
+    datetime,
+    int,
+    str,
+    six.text_type,
+    }
+if sys.version_info[0] < 3:
+    unwrapped_types.add(types.InstanceType)
+unwrapped_types = frozenset(unwrapped_types)
 
 
 def is_security_proxied_or_harmless(obj):