Skip to content

Commit 902ad1c

Browse files
committed
Merge branch 'BUG19169143' into develop
2 parents 1a4c05d + 977ea52 commit 902ad1c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/mysql/connector/optionfiles.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def _parse_options(self, files):
109109

110110
for file_ in files:
111111
try:
112+
if file_ in files[index+1:]:
113+
raise ValueError("Same option file '{0}' occurring more "
114+
"than once in the list".format(file_))
112115
with open(file_, 'r') as op_file:
113116
for line in op_file.readlines():
114117
if line.startswith('!includedir'):
@@ -129,7 +132,7 @@ def _parse_options(self, files):
129132
filename, file_))
130133
files.insert(index+1, filename)
131134

132-
index += 1
135+
index += 1
133136

134137
except (IOError, OSError) as exc:
135138
raise ValueError("Failed reading file '{0}': {1}".format(

tests/test_bugs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,3 +2741,17 @@ def test_duplicate_groups(self):
27412741
}
27422742
self.assertEqual(exp, cnx._read_option_files(
27432743
{'option_files': opt_file}))
2744+
2745+
2746+
class BugOra19169143(tests.MySQLConnectorTests):
2747+
"""BUG#19169143: FAILURE IN RAISING ERROR WITH DUPLICATE OPTION_FILES
2748+
"""
2749+
def test_duplicate_optionfiles(self):
2750+
option_file_dir = os.path.join('tests', 'data', 'option_files')
2751+
files = [
2752+
os.path.join(option_file_dir, 'include_files', '1.cnf'),
2753+
os.path.join(option_file_dir, 'include_files', '2.cnf'),
2754+
os.path.join(option_file_dir, 'include_files', '1.cnf'),
2755+
]
2756+
self.assertRaises(ValueError, mysql.connector.connect,
2757+
option_files=files)

0 commit comments

Comments
 (0)