I am writing a package compatible with both Python 2.7.13
and Python 3.3
, and using the following:
try:
import configparser
except:
from six.moves import configparser
But when I load my .gitmodules
file on Python 2.7
:
configParser = configparser.RawConfigParser( allow_no_value=True )
configFilePath = os.path.join( current_directory, '.gitmodules' )
configParser.read( configFilePath )
It throw the error:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "update.py", line 122, in run
self.create_backstroke_pulls()
File "update.py", line 132, in create_backstroke_pulls
configParser.read( configFilePath )
File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
raise e
ParsingError: File contains parsing errors: /cygdrive/d/.gitmodules
[line 2]: '\tpath = .versioning\n'
[line 3]: '\turl = https://github.com/user/repo\n'
But if I remove the tabs from the .gitmodules
file, it works correctly. On Python 3.3
it does work with tabs, only on Python 2.7.13
it is not working with tabs. How can I make it work without removing the tabs?
The tabs are natively put by git
when I am adding new submodules, so I definitely not remove them from the original file. I have been thinking I could duplicate the file, while removing the tabs. But is there less costly operation for compatibility with Python
?
Related questions: