Home | Trees | Indices | Help |
---|
|
1 # 2 # Licensed to the Apache Software Foundation (ASF) under one 3 # or more contributor license agreements. See the NOTICE file 4 # distributed with this work for additional information 5 # regarding copyright ownership. The ASF licenses this file 6 # to you under the Apache License, Version 2.0 (the 7 # "License"); you may not use this file except in compliance 8 # with the License. You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, 13 # software distributed under the License is distributed on an 14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 # KIND, either express or implied. See the License for the 16 # specific language governing permissions and limitations 17 # under the License. 18 # 19 20 """ 21 Utilities to help Proton support both python2 and python3. 22 """ 23 24 import sys 25 26 # bridge between py2 Queue renamed as py3 queue 27 try: 28 import Queue as queue 29 except ImportError: 30 import queue # type: ignore 31 32 try: 33 from urlparse import urlparse, urlunparse 34 from urllib import quote, unquote # type: ignore 35 except ImportError: 36 from urllib.parse import urlparse, urlunparse, quote, unquote 37 38 PY3 = sys.version_info[0] == 3 39 40 if PY3:42 """Mimic the old 2.x raise behavior: 43 Raise an exception of type t with value v using optional traceback tb 44 """ 45 if v is None: 46 v = t() 47 if tb is None: 48 raise v 49 else: 50 raise v.with_traceback(tb)51 52 55 56 57 unichr = chr 58 else: 59 # the raise syntax will cause a parse error in Py3, so 'sneak' in a 60 # definition that won't cause the parser to barf 61 exec ("""def raise_(t, v=None, tb=None): 62 raise t, v, tb 63 """) 64 6567 return d.iteritems(**kw)68 69 70 unichr = unichr 71
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Mar 15 15:31:12 2019 | http://epydoc.sourceforge.net |