我正在编写一个与Python 2.7.13
和Python 3.3
兼容的包,并使用以下代码:
try:
import configparser
except:
from six.moves import configparser
但是当我在Python 2.7
上加载我的.gitmodules
文件时
configParser = configparser.RawConfigParser( allow_no_value=True )
configFilePath = os.path.join( current_directory, '.gitmodules' )
configParser.read( configFilePath )
它抛出错误:
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'
但是如果我从.gitmodules
文件中删除选项卡,它就能正常工作。在Python 3.3
上,它可以与选项卡一起工作,但在Python 2.7.13
上,它不能与选项卡一起工作。我怎样才能让它在不移除标签的情况下工作?
这些选项卡是在我添加新的子模块时由git
原生放置的,所以我绝对不会从原始文件中删除它们。我一直在想,我可以在删除标签的同时复制文件。但是,为了与Python
兼容,是否有成本较低的操作
相关问题:
https://stackoverflow.com/questions/45415684
复制相似问题