]> granicus.if.org Git - curl/commitdiff
smbserver: fix Python 3 compatibility
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Sun, 13 Oct 2019 19:35:56 +0000 (21:35 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Sun, 13 Oct 2019 20:14:04 +0000 (22:14 +0200)
Python 2's `ConfigParser` module is spelled `configparser` in Python 3.

Closes https://github.com/curl/curl/pull/4484

tests/smbserver.py

index 474e0612bf6e2c22dd9f3d049da3dd07a428eb2f..4fcd34f2b8ecab5b71089439df35b59ecef8e42a 100755 (executable)
 from __future__ import (absolute_import, division, print_function)
 # unicode_literals)
 import argparse
-import ConfigParser
 import os
 import sys
 import logging
 import tempfile
+try: # Python 3
+    import configparser
+except ImportError: # Python 2
+    import ConfigParser as configparser
 
 # Import our curl test data helper
 import curl_test_data
@@ -58,7 +61,7 @@ def smbserver(options):
             f.write("{0}".format(pid))
 
     # Here we write a mini config for the server
-    smb_config = ConfigParser.ConfigParser()
+    smb_config = configparser.ConfigParser()
     smb_config.add_section("global")
     smb_config.set("global", "server_name", "SERVICE")
     smb_config.set("global", "server_os", "UNIX")