1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-04 02:26:16 +01:00

python3 compatibility: raw_input

raw_input has been removed and equals to input in py3. Unfortunatelly no
__future__ statement exists for that. Ensure all modules uses
osc.core.raw_input except osc.cmdln, where there is NameError way
implemented.
This commit is contained in:
Michal Vyskocil 2013-04-09 13:02:24 +02:00 committed by Adrian Schröter
parent b534ae0a6a
commit 5cc72902e0
4 changed files with 12 additions and 4 deletions

View File

@ -17,7 +17,7 @@ except ImportError:
from tempfile import NamedTemporaryFile, mkdtemp from tempfile import NamedTemporaryFile, mkdtemp
from osc.fetch import * from osc.fetch import *
from osc.core import get_buildinfo, store_read_apiurl, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig, is_package_dir from osc.core import get_buildinfo, store_read_apiurl, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig, is_package_dir
from osc.core import get_binarylist, get_binary_file, run_external from osc.core import get_binarylist, get_binary_file, run_external, raw_input
from osc.util import rpmquery, debquery, archquery from osc.util import rpmquery, debquery, archquery
import osc.conf import osc.conf
from . import oscerr from . import oscerr

View File

@ -405,7 +405,11 @@ class RawCmdln(cmd.Cmd):
else: else:
if self.use_rawinput: if self.use_rawinput:
try: try:
line = raw_input(self._prompt_str) try:
#python 2.x
line = raw_input(self._prompt_str)
except NameError:
line = input(self._prompt_str)
except EOFError: except EOFError:
line = 'EOF' line = 'EOF'
else: else:

View File

@ -6554,12 +6554,14 @@ def get_user_projpkgs(apiurl, user, role=None, exclude_projects=[], proj=True, p
def raw_input(*args): def raw_input(*args):
try: try:
import builtins import builtins
func = builtins.input
except ImportError: except ImportError:
#python 2.7 #python 2.7
import __builtin__ as builtins import __builtin__
func = __builtin__.raw_input
try: try:
return builtins.raw_input(*args) return func(*args)
except EOFError: except EOFError:
# interpret ctrl-d as user abort # interpret ctrl-d as user abort
raise oscerr.UserAbort() raise oscerr.UserAbort()

View File

@ -21,6 +21,8 @@ except ImportError:
from urlparse import urlparse from urlparse import urlparse
from httplib import HTTPSConnection from httplib import HTTPSConnection
from .core import raw_input
class TrustedCertStore: class TrustedCertStore:
_tmptrusted = {} _tmptrusted = {}