File tree 2 files changed +36
-1
lines changed 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,7 @@ def _parse_options(self, files):
193
193
for line in op_file .readlines ():
194
194
if line .startswith ('!includedir' ):
195
195
_ , dir_path = line .split (None , 1 )
196
+ dir_path = dir_path .strip ()
196
197
for entry in os .listdir (dir_path ):
197
198
entry = os .path .join (dir_path , entry )
198
199
if entry in files :
@@ -204,6 +205,7 @@ def _parse_options(self, files):
204
205
205
206
elif line .startswith ('!include' ):
206
207
_ , filename = line .split (None , 1 )
208
+ filename = filename .strip ()
207
209
if filename in files :
208
210
raise ValueError (err_msg .format (
209
211
filename , file_ ))
@@ -249,7 +251,6 @@ def read(self, filenames): # pylint: disable=W0221
249
251
else :
250
252
out_file .write (line + '\n ' )
251
253
out_file .seek (0 )
252
- self ._read (out_file , filename )
253
254
except IOError :
254
255
continue
255
256
try :
Original file line number Diff line number Diff line change 35
35
to be created first.
36
36
"""
37
37
38
+ import io
38
39
import os
39
40
import gc
40
41
import tempfile
@@ -2833,3 +2834,36 @@ def test_unsupported_arguments(self):
2833
2834
exp .update (config )
2834
2835
2835
2836
self .assertEqual (exp , new_config )
2837
+
2838
+
2839
+ class BugOra19481761 (tests .MySQLConnectorTests ):
2840
+ """BUG#19481761: OPTION_FILES + !INCLUDE FAILS WITH TRAILING NEWLINE
2841
+ """
2842
+ def test_option_files_with_include (self ):
2843
+ temp_cnf_file = os .path .join (os .getcwd (), 'temp.cnf' )
2844
+ temp_include_file = os .path .join (os .getcwd (), 'include.cnf' )
2845
+
2846
+ cnf_file = open (temp_cnf_file , "w+" )
2847
+ include_file = open (temp_include_file , "w+" )
2848
+
2849
+ config = tests .get_mysql_config ()
2850
+
2851
+ cnf = "[connector_python]\n "
2852
+ cnf += '\n ' .join (['{0} = {1}' .format (key , value )
2853
+ for key , value in config .items ()])
2854
+
2855
+ include_file .write (cnf )
2856
+ cnf_file .write ("!include {0}\n " .format (temp_include_file ))
2857
+
2858
+ cnf_file .close ()
2859
+ include_file .close ()
2860
+
2861
+ try :
2862
+ conn = mysql .connector .connect (option_files = temp_cnf_file )
2863
+ except :
2864
+ self .fail ("Connection failed with option_files argument." )
2865
+
2866
+ self .assertEqual (config , read_option_files (option_files = temp_cnf_file ))
2867
+
2868
+ os .remove (temp_cnf_file )
2869
+ os .remove (temp_include_file )
You can’t perform that action at this time.
0 commit comments