【发布时间】:2017-07-31 12:14:03
【问题描述】:
我正在编写一个与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兼容的操作成本更低吗?
相关问题:
【问题讨论】:
标签: python git python-2.7 tabs python-3.3