[issue30760] configparse module in python3 can not write '%' to config file

2017-06-26 Thread quanyechavshuo

New submission from quanyechavshuo:

Hello,I was using configparser module in python3.6,but find it works not good 
when I try to write '%' to my config file,below is my func:

def update_config_file_key_value(file, section, key_name, key_value):
# 通过configparser模块的调用更新配置文件
# section是[]里面的值
if os.path.exists(file) == False:
os.system("touch %s" % file)
import configparser
config = configparser.ConfigParser()
config.read(file)
sectionList = config.sections()
if section not in sectionList:
config.add_section(section)
config.set(section, key_name, str(key_value))
with open(file, 'w') as f:
config.write(f)

When I use it as:
update_config_file_key_value('config.ini','default','cookie',"123")
it works well,but below not ok:
update_config_file_key_value('config.ini','default','cookie',"%123")
and below not ok:
update_config_file_key_value('config.ini','default','cookie',"123%")
and below not ok:
update_config_file_key_value('config.ini','default','cookie',"12%3")

That's to say,configparser can not write '%' to config file.

--
messages: 296865
nosy: quanyechavshuo
priority: normal
severity: normal
status: open
title: configparse module in python3 can not write '%' to config file
type: behavior
versions: Python 3.6

___
Python tracker 
<http://bugs.python.org/issue30760>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29831] os.path.exists seems can not recgnize "~"

2017-03-16 Thread quanyechavshuo

New submission from quanyechavshuo:

os.system is ok to recgnize "~",but os.path.exists can not recgnize "~".

eg:

#1.py:
import os
os.system("ls -al ~/.zshrc")

python3 1.py

output:
-rw-r--r--  1 root  wheel  5391  3 14 18:12 /var/root/.zshrc


#2.py:
import os
a=os.path.exists("~/.zshrc")
print(a)

python3 2.py

output:
False

--
messages: 289740
nosy: quanyechavshuo
priority: normal
severity: normal
status: open
title: os.path.exists seems can not recgnize "~"
type: behavior

___
Python tracker 
<http://bugs.python.org/issue29831>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com