pyramid.compat¶
Deprecated since version 1.10: pyramid.compat will be removed in Pyramid 2.0.
The functionality is no longer necessary, as Pyramid 2.0 drops support for Python 2.
The pyramid.compat module provides platform and version compatibility for
Pyramid and its add-ons across Python platform and version differences.  APIs
will be removed from this module over time as Pyramid ceases to support
systems which require compatibility imports.
- ascii_native_(s)[source]¶
 Python 3: If
sis an instance oftext_type, returns.encode('ascii'), otherwise returnstr(s, 'ascii', 'strict')Python 2: If
sis an instance oftext_type, returns.encode('ascii'), otherwise returnstr(s)
- binary_type¶
 Binary type for this platform. For Python 3, it's
bytes. For Python 2, it'sstr.
- bytes_(s, encoding='latin-1', errors='strict')[source]¶
 If
sis an instance oftext_type, returns.encode(encoding, errors), otherwise returns
- class_types¶
 Sequence of class types for this platform. For Python 3, it's
(type,). For Python 2, it's(type, types.ClassType).
- configparser¶
 On Python 2, the
ConfigParsermodule, on Python 3, theconfigparsermodule.
- exec_(code, globs=None, locs=None)¶
 Exec code in a compatible way on both Python 2 and 3.
- im_func¶
 On Python 2, the string value
im_func, on Python 3, the string value__func__.
- input_(v)¶
 On Python 2, the
raw_inputfunction, on Python 3, theinputfunction.
- integer_types¶
 Sequence of integer types for this platform. For Python 3, it's
(int,). For Python 2, it's(int, long).
- long¶
 Long type for this platform. For Python 3, it's
int. For Python 2, it'slong.
- pickle¶
 cPicklemodule if it exists,picklemodule otherwise.
- PY3¶
 Trueif running on Python 3,Falseotherwise.
- PYPY¶
 Trueif running on PyPy,Falseotherwise.
- reraise(tp, value, tb=None)[source]¶
 Reraise an exception in a compatible way on both Python 2 and Python 3, e.g.
reraise(*sys.exc_info()).
- string_types¶
 Sequence of string types for this platform. For Python 3, it's
(str,). For Python 2, it's(basestring,).
- SimpleCookie[source]¶
 On Python 2, the
Cookie.SimpleCookieclass, on Python 3, thehttp.cookies.SimpleCookiemodule.
- text_(s, encoding='latin-1', errors='strict')[source]¶
 If
sis an instance ofbinary_type, returns.decode(encoding, errors), otherwise returns
- text_type¶
 Text type for this platform. For Python 3, it's
str. For Python 2, it'sunicode.
- native_(s, encoding='latin-1', errors='strict')[source]¶
 Python 3: If
sis an instance oftext_type, returns, otherwise returnstr(s, encoding, errors)Python 2: If
sis an instance oftext_type, returns.encode(encoding, errors), otherwise returnstr(s)
- urlparse¶
 urlparsemodule on Python 2,urllib.parsemodule on Python 3.
- url_quote¶
 urllib.quotefunction on Python 2,urllib.parse.quotefunction on Python 3.
- url_quote_plus¶
 urllib.quote_plusfunction on Python 2,urllib.parse.quote_plusfunction on Python 3.
- url_unquote¶
 urllib.unquotefunction on Python 2,urllib.parse.unquotefunction on Python 3.
- url_encode¶
 urllib.urlencodefunction on Python 2,urllib.parse.urlencodefunction on Python 3.
- url_open¶
 urllib2.urlopenfunction on Python 2,urllib.request.urlopenfunction on Python 3.
- url_unquote_text(v, encoding='utf-8', errors='replace')¶
 On Python 2, return
url_unquote(v).decode(encoding(encoding, errors)); on Python 3, return the result ofurllib.parse.unquote.
- url_unquote_native(v, encoding='utf-8', errors='replace')¶
 On Python 2, return
native_(url_unquote_text_v, encoding, errors)); on Python 3, return the result ofurllib.parse.unquote.