Commit 9f343717 authored by vapier's avatar vapier Committed by Commit bot

handle configparser rename in python3

The ConfigParser module was renamed to configparser, so update the
two modules using it to try both (and default to the new name).

Review-Url: https://codereview.chromium.org/2076653002
parent d60367ba
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
Includes support for svn, git-svn and git. Includes support for svn, git-svn and git.
""" """
import ConfigParser
import fnmatch import fnmatch
import logging import logging
import os import os
...@@ -17,6 +16,12 @@ import subprocess ...@@ -17,6 +16,12 @@ import subprocess
import sys import sys
import tempfile import tempfile
# The configparser module was renamed in Python 3.
try:
import configparser
except ImportError:
import ConfigParser as configparser
import patch import patch
import scm import scm
import subprocess2 import subprocess2
...@@ -258,7 +263,7 @@ class SvnConfig(object): ...@@ -258,7 +263,7 @@ class SvnConfig(object):
self.svn_config_dir = os.path.expanduser( self.svn_config_dir = os.path.expanduser(
os.path.join('~', '.subversion')) os.path.join('~', '.subversion'))
svn_config_file = os.path.join(self.svn_config_dir, 'config') svn_config_file = os.path.join(self.svn_config_dir, 'config')
parser = ConfigParser.SafeConfigParser() parser = configparser.SafeConfigParser()
if os.path.isfile(svn_config_file): if os.path.isfile(svn_config_file):
parser.read(svn_config_file) parser.read(svn_config_file)
else: else:
......
...@@ -36,7 +36,6 @@ against by using the '--rev' option. ...@@ -36,7 +36,6 @@ against by using the '--rev' option.
from __future__ import print_function from __future__ import print_function
import ConfigParser
import cookielib import cookielib
import errno import errno
import fnmatch import fnmatch
...@@ -56,6 +55,12 @@ import urlparse ...@@ -56,6 +55,12 @@ import urlparse
from multiprocessing.pool import ThreadPool from multiprocessing.pool import ThreadPool
# The configparser module was renamed in Python 3.
try:
import configparser
except ImportError:
import ConfigParser as configparser
# The md5 module was deprecated in Python 2.5. # The md5 module was deprecated in Python 2.5.
try: try:
from hashlib import md5 from hashlib import md5
...@@ -2241,7 +2246,7 @@ def LoadSubversionAutoProperties(): ...@@ -2241,7 +2246,7 @@ def LoadSubversionAutoProperties():
subversion_config = os.path.expanduser("~/.subversion/config") subversion_config = os.path.expanduser("~/.subversion/config")
if not os.path.exists(subversion_config): if not os.path.exists(subversion_config):
return {} return {}
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
config.read(subversion_config) config.read(subversion_config)
if (config.has_section("miscellany") and if (config.has_section("miscellany") and
config.has_option("miscellany", "enable-auto-props") and config.has_option("miscellany", "enable-auto-props") and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment