jaraco / configparser Goto Github PK
View Code? Open in Web Editor NEWbackport of configparser from Python's stdlib
License: MIT License
backport of configparser from Python's stdlib
License: MIT License
To wrap up dropping Python 2 support after this commit:
the README should be updated, as it still mentions Python 2
in several places.
Original report by Éric Araujo (Bitbucket: Merwok, GitHub: Merwok).
Hi! I just noticed the backport; have you announced it somewhere?
The x.yrz scheme you’re using does not respect PEP 386.
class M(dict):
def __setitem__(self, key, value):
if len(value) > 1:
return
if key in self:
items = self[key]
new = value[0] if type(value) is list else value
if new not in items:
items.append(new)
else:
super().__setitem__(key, value)
config_parser_args
{'allow_no_value': True, 'strict': False, 'dict_type': <class 'main.main..M'>}
get_value = ConfigParser(**config_parser_args)
Raising the following Error:
AttributeError: 'ConfigParser' object has no attribute 'default_section'
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
/home/yrachman/os-client/tmp/python-test/venv-3.6/lib/python3.6/site-packages/backports/configparser/init.py(1383)_options()
-> if self._name != self._parser.default_section:
python -V Python 3.6.8
configparser 5.0.0
Removing dict_type, works well
Had the following code working till python3.5 w/ configparser 4.0.2
It seems that setuptools can't handle non-ascii setup.cfg. If I delete the author from setup.cfg it works fine.
$ python setup.py bdist_rpm
running bdist_rpm
running egg_info
writing src/configparser.egg-info/PKG-INFO
writing dependency_links to src/configparser.egg-info/dependency_links.txt
writing requirements to src/configparser.egg-info/requires.txt
writing top-level names to src/configparser.egg-info/top_level.txt
reading manifest file 'src/configparser.egg-info/SOURCES.txt'
writing manifest file 'src/configparser.egg-info/SOURCES.txt'
writing 'build/bdist.linux-x86_64/rpm/SPECS/configparser.spec'
running sdist
running check
creating configparser-3.7.4
creating configparser-3.7.4/src
creating configparser-3.7.4/src/backports
creating configparser-3.7.4/src/backports/configparser
creating configparser-3.7.4/src/configparser.egg-info
copying files to configparser-3.7.4...
copying LICENSE -> configparser-3.7.4
copying README.rst -> configparser-3.7.4
copying setup.cfg -> configparser-3.7.4
copying setup.py -> configparser-3.7.4
copying src/configparser.py -> configparser-3.7.4/src
copying src/backports/__init__.py -> configparser-3.7.4/src/backports
copying src/backports/configparser/__init__.py -> configparser-3.7.4/src/backports/configparser
copying src/backports/configparser/helpers.py -> configparser-3.7.4/src/backports/configparser
copying src/configparser.egg-info/PKG-INFO -> configparser-3.7.4/src/configparser.egg-info
copying src/configparser.egg-info/SOURCES.txt -> configparser-3.7.4/src/configparser.egg-info
copying src/configparser.egg-info/dependency_links.txt -> configparser-3.7.4/src/configparser.egg-info
copying src/configparser.egg-info/requires.txt -> configparser-3.7.4/src/configparser.egg-info
copying src/configparser.egg-info/top_level.txt -> configparser-3.7.4/src/configparser.egg-info
Writing configparser-3.7.4/setup.cfg
Creating tar archive
removing 'configparser-3.7.4' (and everything under it)
copying dist/configparser-3.7.4.tar.gz -> build/bdist.linux-x86_64/rpm/SOURCES
building RPMs
sh: 1: editable: not found
sh: 1: string-like: not found
rpmbuild -ba --define __python python3 --define _topdir /tmp/configparser/build/bdist.linux-x86_64/rpm --clean build/bdist.linux-x86_64/rpm/SPECS/configparser.spec
sh: 1: editable: not found
sh: 1: string-like: not found
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.X7ocP0
+ umask 022
+ cd /tmp/configparser/build/bdist.linux-x86_64/rpm/BUILD
+ cd /tmp/configparser/build/bdist.linux-x86_64/rpm/BUILD
+ rm -rf configparser-3.7.4
+ /bin/gzip -dc /tmp/configparser/build/bdist.linux-x86_64/rpm/SOURCES/configparser-3.7.4.tar.gz
+ /bin/tar -xvvof -
drwxr-xr-x israel.tsadok/dev 0 2019-03-26 10:16 configparser-3.7.4/
-rw-r--r-- israel.tsadok/dev 9992 2019-03-26 10:05 configparser-3.7.4/README.rst
drwxr-xr-x israel.tsadok/dev 0 2019-03-26 10:16 configparser-3.7.4/src/
drwxr-xr-x israel.tsadok/dev 0 2019-03-26 10:16 configparser-3.7.4/src/backports/
drwxr-xr-x israel.tsadok/dev 0 2019-03-26 10:16 configparser-3.7.4/src/backports/configparser/
-rw-r--r-- israel.tsadok/dev 7648 2019-03-26 10:05 configparser-3.7.4/src/backports/configparser/helpers.py
-rw-r--r-- israel.tsadok/dev 55398 2019-03-26 10:05 configparser-3.7.4/src/backports/configparser/__init__.py
-rw-r--r-- israel.tsadok/dev 211 2019-03-26 10:05 configparser-3.7.4/src/backports/__init__.py
-rw-r--r-- israel.tsadok/dev 1560 2019-03-26 10:05 configparser-3.7.4/src/configparser.py
drwxr-xr-x israel.tsadok/dev 0 2019-03-26 10:16 configparser-3.7.4/src/configparser.egg-info/
-rw-r--r-- israel.tsadok/dev 23 2019-03-26 10:16 configparser-3.7.4/src/configparser.egg-info/top_level.txt
-rw-r--r-- israel.tsadok/dev 120 2019-03-26 10:16 configparser-3.7.4/src/configparser.egg-info/requires.txt
-rw-r--r-- israel.tsadok/dev 1 2019-03-26 10:16 configparser-3.7.4/src/configparser.egg-info/dependency_links.txt
-rw-r--r-- israel.tsadok/dev 12559 2019-03-26 10:16 configparser-3.7.4/src/configparser.egg-info/PKG-INFO
-rw-r--r-- israel.tsadok/dev 359 2019-03-26 10:16 configparser-3.7.4/src/configparser.egg-info/SOURCES.txt
-rw-r--r-- israel.tsadok/dev 990 2019-03-26 10:16 configparser-3.7.4/setup.cfg
-rw-r--r-- israel.tsadok/dev 120 2019-03-26 10:05 configparser-3.7.4/setup.py
-rw-r--r-- israel.tsadok/dev 12559 2019-03-26 10:16 configparser-3.7.4/PKG-INFO
-rw-r--r-- israel.tsadok/dev 1050 2019-03-26 10:05 configparser-3.7.4/LICENSE
+ STATUS=0
+ [ 0 -ne 0 ]
+ cd configparser-3.7.4
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.c5mbxG
+ umask 022
+ cd /tmp/configparser/build/bdist.linux-x86_64/rpm/BUILD
+ cd configparser-3.7.4
+ python3 setup.py build
Traceback (most recent call last):
File "setup.py", line 5, in <module>
package_dir={'': 'src'},
File "/tmp/venv/lib/python3.6/site-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "/tmp/venv/lib/python3.6/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
dist.parse_config_files(ignore_option_errors=True)
File "/tmp/venv/lib/python3.6/site-packages/setuptools/dist.py", line 702, in parse_config_files
self._parse_config_files(filenames=filenames)
File "/tmp/venv/lib/python3.6/site-packages/setuptools/dist.py", line 599, in _parse_config_files
(parser.read_file if six.PY3 else parser.readfp)(reader)
File "/usr/lib/python3.6/configparser.py", line 718, in read_file
self._read(f, source)
File "/usr/lib/python3.6/configparser.py", line 1015, in _read
for lineno, line in enumerate(fp, start=1):
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 108: ordinal not in range(128)
error: Bad exit status from /var/tmp/rpm-tmp.c5mbxG (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.c5mbxG (%build)
error: command 'rpmbuild' failed with exit status 1
This happens in Python 2.7 and 3.7, with setuptools 40.8.0.
Original report by Barry Warsaw (Bitbucket: warsaw, GitHub: warsaw).
Over in Ubuntu, we inherit Debian's python-configparser package, which currently provides configparser 3.3.0r2. Normally, this package isn't hugely depended on by other packages, so it doesn't get installed very often. Recently one of our main packages created a dependency on configparser and when it got installed lots of things broke. We ended up having to rewrite the code to not depend on configparser, and thus relegating it back away from our main repository. We must actively recommend against installing it.
Here are examples of things it broke. Some have been fixed in the broken package, but a few (e.g. the virtualenv problem) is currently fixable only by de-installing configparser.
https://bugs.launchpad.net/ubuntu/+source/python-virtualenv/+bug/1156704
https://bugs.launchpad.net/software-center/+bug/1038429
https://bugs.launchpad.net/ubuntu/+source/ubuntuone-client/+bug/1198480
Unfortunately, I don't have a lot of time right now for further investigation, but I wanted to file the bug upstream for tracking purposes.
Original report by Klaus Alexander Seistrup (Bitbucket: kseistrup, GitHub: kseistrup).
Standing in a directory with a setup.cfg file, using python2.7:
#!python
>>> import configparser
>>> parser=configparser.ConfigParser()
>>> parser.read('setup.cfg')
[]
>>> parser.read(u'setup.cfg')
[u'setup.cfg']
>>>
So if there accidentally is a file byt the name of s, e, t, u, p, c, f, or g, that file will be read:
#!python
$ ln -s setup.cfg s
$ python2.7
>>> import configparser
>>> parser=configparser.ConfigParser()
>>> parser.read('setup.cfg')
['s']
>>>
Hint: ConfigParser()'s .read() method says that the filename should only be included in the file list if the name is a unicode instance, and thus a plain string object gets treated as a list.
Original report by Joshua Paul (Bitbucket: jpaulLD, GitHub: jpaulLD).
Release notes mention 3.5.0 and also compliant versioning. When can we expect to see that on pypi?
The new release breaks installation of psycopg==2.6.2. (and
2.6.1`) with the following TB:
Collecting psycopg2==2.6.2
Downloading https://files.pythonhosted.org/packages/7b/a8/dc2d50a6f37c157459cd18bab381c8e6134b9381b50fbe969997b2ae7dbc/psycopg2-2.6.2.tar.gz (376kB)
100% |████████████████████████████████| 378kB 32.0MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-ghXlER/psycopg2/setup.py", line 511, in <module>
use_pydatetime = int(parser.get('build_ext', 'use_pydatetime'))
File "/home/circleci/.local/lib/python2.7/site-packages/backports/configparser/__init__.py", line 792, in get
d = self._unify_values(section, vars)
File "/home/circleci/.local/lib/python2.7/site-packages/backports/configparser/__init__.py", line 1162, in _unify_values
raise NoSectionError(section)
backports.configparser.NoSectionError: No section: 'build_ext'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-ghXlER/psycopg2/
Downgrading to configparser==3.5.1
solved the problem.
Original report by Matt Braymer-Hayes (Bitbucket: mattayes, GitHub: mattayes).
There appears to be an issue with the configparser installation process where the backports module is missing the __init__.py
file. You can find more details in this closed issue in the backports repo: https://bitbucket.org/brandon/backports/issues/5/missing-__init__py.
I don't run into this issue in Python 2.7.12, though I do with Python 2.7.14. Let me know what extra details you need!
Original report by Anonymous.
When setting up the ConfigParser to use ExtendedInterpolation an TypeError is raised.
config = ConfigParser(interpolation=ExtendedInterpolation)
config.read('my_config_file.cfg')
File "/usr/lib/python2.7/site-packages/configparser-3.5.0b2-py2.7.egg/backports/configparser/init.py", line 1146
in _join_multiline_values
name, val)
TypeError: unbound method before_read() must be called with BasicInterpolation instance as first argument (got ConfigParser instance instead)
method signature is: def before_read(self, parser, section, option, value): ...
but parser is not given in line 1144/1146
options[name] = self._interpolation.before_read(self, section, name, val)
We use Python for a large number of projects in our commercial environment. As part of our build system we peg the revisions of all of our dependencies to ensure consistent, reliable build results. This morning we discovered several of our projects started to fail because they could no longer download v4.0.1 of this package to build with. Closer examination of the problem lead me to discover this package had been removed from pypi.org.
Please restore this version of the package and I would strongly suggest you avoid removing packages from pypi.org, precisely for this reason. If there is a critical error / bug in a version simply release a new, updated version to fix the problem, and leave the old package on the public repo. This will save your users a great deal of grief in the future.
Original report by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco).
Per the documentation for backports, the backports modules should be using the pkgutil technique for declaring namespaces.
Although it doesn't say it explicitly in the guidance, the only place where namespace_packages=
is mentioned is in the guidance for pkg_resources namespaces. And if you look at the examples or other backports projects, you see they do not define a non-degenerate namespace_packages
.
By declaring the namespace_packages, you signal setuptools to declare that namespace and to generate the nspkg.pth file that leads to backports
being imported at startup. It is the root cause of pytest-4014 and is likely implicated in #20, #19, and #17.
I believe you can remove that declaration without any adverse effects.
I recently switched to make DeprecatedWarnings behave like errors using python-2.7.12, pytest-4.3.1, pytest-pylint-0.14.0, pylint-1.9.2, ie, running 'pytest --pylint -W error some_scripts.py' and I my CI started to fail. I had to disable the '-W error' option for now, but I would really like to enable it again. Is this something that can be fixed in configparser?
The warning I get is the following:
=============================== warnings summary ===============================
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311
.tox/py27-pylint/lib/python2.7/site-packages/backports/configparser/__init__.py:1311:
DeprecationWarning: You passed a bytestring. Implicitly decoding as UTF-8 string. This will not work on Python 3. Please switch to using Unicode strings across the board.
section, _, _ = self._validate_value_types(section=section)
-- Docs: https://docs.pytest.org/en/latest/warnings.html
I use requires.io for monitoring my dependencies. (https://requires.io/github/h3llrais3r/Auto-Subliminal/requirements/?branch=development)
It keeps complaining about configparser being outdated because there is a newer version 3.8.0.
However it's not possible to install it through pip.
Any idea how we can can rid of this version, as it seems to be the same release as 3.7.3?
Original report by Shawn Butts (Bitbucket: shawnbutts, GitHub: shawnbutts).
The summary is that I have a salt state that installed the latest version of configparser via pip-2.6. After 3.5.0, this breaks salt from ever running again. If I remove 3.5.0 and install 3.4.x, it works.
Original report by flashbuster (Bitbucket: flashbuster, GitHub: Unknown).
According to the docs, the import on python2 should be "import configparser", but that does import the built in version:
#!python
>>> import configparser
>>> configparser
<module 'configparser' from '/home/buster/.virtualenvs/cfgparsertest/local/lib/python2.7/site-packages/configparser/__init__.pyc'>
>>> from backports import configparser
>>> configparser
<module 'backports.configparser' from '/home/buster/.virtualenvs/cfgparsertest/local/lib/python2.7/site-packages/backports/configparser/__init__.pyc'>
Original report by Frederik Rietdijk (Bitbucket: FRidh, GitHub: FRidh).
If we have several backport packages (configparser
, backports.shutil_get_terminal_size
, backports.ssl_match_hostname
), then we get an ImportError
when we try to use these packages. At least
python -c 'import backports.shutil_get_terminal_size'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'backports.shutil_get_terminal_size'
We fixed the issue with
https://github.com/FRidh/nixpkgs/blob/d7378da0280ebc0b59d0d198fd86b2d4a9eace41/pkgs/development/python-modules/configparser/0001-namespace-fix.patch
Discussion on the issue.
NixOS/nixpkgs#23855
Thanks for making this package! Due to #27 I just upgraded configparser and 3.7.0, unfortunately it breaks flake8 on Python 2.7.15:
Traceback (most recent call last):
File "/Users/pcloke/.virtualenvs/my_venv/bin/flake8", line 7, in <module>
from flake8.main.cli import main
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/flake8/main/cli.py", line 2, in <module>
from flake8.main import application
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/flake8/main/application.py", line 14, in <module>
from flake8.main import options
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/flake8/main/options.py", line 4, in <module>
from flake8.main import vcs
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/flake8/main/vcs.py", line 4, in <module>
from flake8.main import mercurial
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/flake8/main/mercurial.py", line 7, in <module>
import configparser
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/configparser.py", line 12, in <module>
from backports.configparser import (
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/backports/configparser/__init__.py", line 139, in <module>
from backports.configparser.helpers import OrderedDict as _default_dict
File "/Users/pcloke/.virtualenvs/my_venv/lib/python2.7/site-packages/backports/configparser/helpers.py", line 193, in <module>
dict(__metaclass__=abc.ABCMeta),
File "/Users/pcloke/.virtualenvs/my_venv/bin/../lib/python2.7/abc.py", line 87, in __new__
cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: type() argument 1 must be string, not newstr
Let me know if I can provide any other information! This seems to break on both Linux and macOS. Rolling back to 3.5.3 fixed this issue for me.
With the 3.5.1 release, I made an 0.0.1 release because it seems to me the versions of this project are attempting to track with Python releases... and I wanted to be careful to fix the packaging without conflicting too much with the existing version scheme. Maybe it should have been 3.5.0r2... but I'd rather use simple version numbers.
Going forward, I'm tempted to adopt semver and allow the version numbers to deviate from what's in stdlib. I'm open to thoughts or suggestions.
configparser uses absolute imports to import from backports.configparser
, when the globally installed version may not be compatible with what is running.
This is an import search order problem and I'm not sure who to blame or how to fix it properly.
A docker session that demonstrates this:
$ docker run --rm -it debian:sid /bin/bash
# apt update && apt install python-pip python-configparser
-- snip --
Setting up python-configparser (3.5.0b2-3) ...
-- snip --
# pip install --user -U configparser
Collecting configparser
Downloading https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Installing collected packages: configparser
Successfully installed configparser-4.0.2
# python -c "import configparser"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/.local/lib/python2.7/site-packages/configparser.py", line 11, in <module>
from backports.configparser import (
ImportError: cannot import name ConverterMapping
#
sys.path
looks correct:
[
'',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/root/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages'
]
The user site-packages comes before global dist-packages, so I'm not sure why it's importing from the latter first.
This was reported here: MozillaSecurity/fuzzfetch#50
Why are special charakters are not supportet yet ?
placeholder : 🢂
placeholder : ➲
The output is 🢠from placeholder : 🢂
. How i can fix it
When i change 🢂 to \U0001F882 the result is:
print('🢂')
test = '\U0001F882'
print(type(test))
print(test)
test2 = config.get('Hurra!!!', 'placeholder')
print(type(test2))
print(test2)
Output is:
🢂
<class 'str'>
🢂
<class 'str'>
\U0001F882
https://tidelift.com/subscription/pkg/pypi-configparser, in the changelog and readme, seems to be invalid, showing a Page not found 404 error page.
Following on #25, and having stumbled a few times by mis-remembering this unusual versioning scheme, I'd rather switch to semver for this backport. Now that 3.8 has been released, I'll use 4.0.0 for the semver-based releases.
Currently setup.cfg
reports
python_requires =>=2.6
It's a little unclear what your maximum supported version is, but I've run across some packages that specify configparser as a dependency without a marker and it's being included in environments intended for recent versions (like 3.7 and 3.8).
I think the intent from the readme is that it should not be necessary on 3.6+, so I wondered if you would accept a pull request that sets something like
python_requires = >=2.6,<3.6"
Original report by Anonymous.
root@428c4d7701c1:/usr/src/app# python -c 'import configparser'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/conda/lib/python2.7/site-packages/configparser.py", line 12, in <module>
from backports.configparser import (
ImportError: No module named configparser
root@428c4d7701c1:/usr/src/app# pip uninstall configparser && pip install configparser
Uninstalling configparser-3.5.0:
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0-py2.7.egg-info
/opt/conda/lib/python2.7/site-packages/configparser.py
/opt/conda/lib/python2.7/site-packages/configparser.pyc
Proceed (y/n)? y
Successfully uninstalled configparser-3.5.0
Collecting configparser
Downloading configparser-3.5.0.tar.gz
Building wheels for collected packages: configparser
Running setup.py bdist_wheel for configparser ... done
Stored in directory: /root/.cache/pip/wheels/1c/bd/b4/277af3f6c40645661b4cd1c21df26aca0f2e1e9714a1d4cda8
Successfully built configparser
Installing collected packages: configparser
Successfully installed configparser-3.5.0
root@428c4d7701c1:/usr/src/app# python -c 'import configparser'
root@428c4d7701c1:/usr/src/app# pip uninstall configparser
Uninstalling configparser-3.5.0:
/opt/conda/lib/python2.7/site-packages/backports/configparser/__init__.py
/opt/conda/lib/python2.7/site-packages/backports/configparser/__init__.pyc
/opt/conda/lib/python2.7/site-packages/backports/configparser/helpers.py
/opt/conda/lib/python2.7/site-packages/backports/configparser/helpers.pyc
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0-py2.7-nspkg.pth
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/DESCRIPTION.rst
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/INSTALLER
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/METADATA
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/RECORD
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/WHEEL
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/metadata.json
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/namespace_packages.txt
/opt/conda/lib/python2.7/site-packages/configparser-3.5.0.dist-info/top_level.txt
/opt/conda/lib/python2.7/site-packages/configparser.py
/opt/conda/lib/python2.7/site-packages/configparser.pyc
Proceed (y/n)n
Original report by Charles Morton (Bitbucket: cgmorton, GitHub: cgmorton).
NoOptionError is not being raised when I try to get the value from a key that is not in the INI file. The following code snippet will hopefully demonstrate the problem. What happens for me is that the value for "bar" is set to None, instead of raising the error. I have the same problem if I read the values from an INI file.
I am running Python 2.7.12 and configparser 3.5.0, and installed configparser using Anaconda. Sorry in advance if I missed something really obvious or this is the expected behavior!
#!python
from backports import configparser
parser = configparser.ConfigParser()
parser.read_string(unicode("""
[options]
foo = 10
"""))
# This works
print('foo', parser['options'].get('foo'))
# I thought this would raise a NoOptionError, but instead returns None
print('bar', parser['options'].get('bar'))
mkdir test
cd test
virtualenv --no-setuptools py
wget https://github.com/buildout/buildout/blob/master/bootstrap/bootstrap.py
# Add file buildout.cfg
py/bin/python bootstrap.py
bin/buildout
Where:
buildout.cfg
[buildout]
parts = configparser
index = https://pypi.org/simple/
versions = versions
[configparser]
recipe = zc.recipe.egg
eggs=configparser
[versions]
setuptools=26.1.1
zc.buildout=1.7.1
Then I get the error:
Getting distribution for 'zc.buildout==1.7.1'.
Got zc.buildout 1.7.1.
Getting distribution for 'setuptools==26.1.1'.
warning: no files found matching '*' under directory 'setuptools/_vendor'
Got setuptools 26.1.1.
Upgraded:
zc.buildout version 1.7.1,
setuptools version 26.1.1;
restarting.
Generated script '/tmp/test/bin/buildout'.
/home/user/.buildout/eggs/setuptools-26.1.1-py2.7.egg/pkg_resources/__init__.py:188: RuntimeWarning: You have iterated over the result of pkg_resources.parse_version. This is a legacy behavior which is inconsistent with the new version class introduced in setuptools 8.0. In most cases, conversion to a tuple is unnecessary. For comparison of versions, sort the Version instances directly. If you have another use case requiring the tuple, please file a bug with the setuptools project describing that need.
stacklevel=1,
Getting distribution for 'zc.recipe.egg<2dev'.
Got zc.recipe.egg 1.3.2.
Installing configparser.
Getting distribution for 'configparser'.
zip_safe flag not set; analyzing archive contents...
backports.__init__: module references __path__
Installing configparser 3.7.4
Caused installation of a distribution:
UNKNOWN 0.0.0
with a different project name.
Installing configparser 3.7.4
Caused installation of a distribution:
UNKNOWN 0.0.0
with a different version.
Got None.
Getting distribution for 'configparser'.
zip_safe flag not set; analyzing archive contents...
backports.__init__: module references __path__
Installing configparser 3.7.4
Caused installation of a distribution:
UNKNOWN 0.0.0
with a different project name.
Installing configparser 3.7.4
Caused installation of a distribution:
UNKNOWN 0.0.0
with a different version.
Got None.
While:
Installing configparser.
Error: There is a version conflict.
We already have: UNKNOWN 0.0.0
In the line if PY2 and isinstance(filenames, bytes) and sys.py3kwarning:
, the addition of and sys.py3kwarning
makes it so flake8 can't read config files. sys.py3kwarning
seems to only be True
if you pass -3
to the python interpreter, and this is not set by default in flake8
.
Why was it removed from pypi?
I'm using pipenv and have configparser==4.0.1 in my Pipfile.lock
Luckily this is not a web app that's auto deployed using Pipfiles.lock and it only breaks my local environment. But it may have very bad consequences for others!
Running tests on Python 2.7, I see this warning:
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_exceptions
/Users/jaraco/code/public/configparser/src/backports/configparser/__init__.py:980: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if key == self.default_section:
Original report by tinche (Bitbucket: tinche, GitHub: tinche).
Hi,
I was looking forward to using this on PyPy as well, but I can't seem to install it:
#!bash
(dbrpypy)tin@tin-desktop ~/pg/dbrpypy> pip install configparser
Downloading/unpacking configparser
Running setup.py egg_info for package configparser
error: <fdopen>: Bad file descriptor
Complete output from command python setup.py egg_info:
running egg_info
writing pip-egg-info/configparser.egg-info/PKG-INFO
error: <fdopen>: Bad file descriptor
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/tin/pg/dbrpypy/build/configparser
Storing complete log in /home/tin/.pip/pip.log
(dbrpypy)tin@tin-desktop ~/pg/dbrpypy> pypy --version
Python 2.7.3 (2.1.0+dfsg-3~ppa1, Sep 15 2013, 01:10:06)
[PyPy 2.1.0 with GCC 4.6.3]
(dbrpypy)tin@tin-desktop ~/pg/dbrpypy> pip --version
pip 1.3.1 from /home/tin/pg/dbrpypy/site-packages/pip-1.3.1-py2.7.egg (python 2.7
Am I doing something wrong?
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 210: character maps to
Original report by Éric Araujo (Bitbucket: Merwok, GitHub: Merwok).
This is downright evil :)
reload(sys)
sys.setdefaultencoding('utf8')
If I need to support an old Python version that does not support Unicode in setup.py, I just use raw UTF-8 bytes for the name.
The library does currently does not handle File Not Found Error.
Scenario:
Consider a situation where config/test.ini is not created yet.
config = configparser.ConfigParser() config.read("config/test.ini") key = config['db']['key']
Expected Response:
File not found error: The file test.ini is not found
Actual Response:
Key Error: 'db'
Sections can be intended is specified in the documentation.
When I read the indented section, its throwing section not found an error in python 3.8
as per Documentation
[You can use comments]
# like this
; or this
[Sections Can Be Indented]
can_values_be_as_well = True
does_that_mean_anything_special = False
purpose = formatting for readability
but this is not working.
check this
if i read an indented section, its showing section not found.
my file:
[section]
a = 0.3
[subsection]
b = 123
import configparser
conf = configparser.ConfigParser()
conf.read("./test.conf")
a = conf['section']['a']
print(a)
Output of a:
0.3
[subsection]
b = 123
Expected a : 0.3 only
But Section b is not found
We've been having some issues with the build of this package in conda-forge. Our build is just using pip install
internally to install the package, but it runs into some kind of encoding error. More details and logs can be found in issue ( conda-forge/configparser-feedstock#21 ).
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 160: character maps to <undefined>
my CI got broken after the configparser==5.3.2 release today when using tox.ini to configure pytest-flake8.
for some reason, the tox.ini configuration to ignore E501 does not work now and it gets reported as an error. configparser==3.5.1 works as expected.
all other modules have not changed.
--error--
my_file.py:15:80: E501 line too long (87 > 79 characters)
--versions--
python==2.7.2,apipkg==1.5,astroid==1.4.9,atomicwrites==1.2.1,attrs==18.2.0,backports.functools-lru-cache==1.5,configparser==3.5.2,coverage==4.5.2,enum34==1.1.6,execnet==1.5.0,flake8==3.5.0,formic==0.9b8,funcsigs==1.0.2,futures==3.2.0,isort==4.3.4,jenkinsapi==0.3.3,junit-xml==1.7,lazy-object-proxy==1.3.1,mccabe==0.6.1,mock==1.0.0,more-itertools==5.0.0,pluggy==0.7.1,psutil==5.1.3,py==1.7.0,pycodestyle==2.3.1,pyflakes==1.6.0,Pygments==2.2.0,pylint==1.6.5,pytest==3.6.4,pytest-cov==2.5.1,pytest-flake8==1.0.2,pytest-forked==1.0.1,pytest-pylint==0.12.0,pytest-xdist==1.22.5,pytz==2018.9,requests==2.13.0,retrying==1.3.3,six==1.12.0,suds==0.4,wrapt==1.11.1,xmltodict==0.10.2
--tox.ini--
[flake8]
# C901 '*' is too complex
# E402 module level import not at top of file
# E501 line too long
exclude = {[base]exclude}
ignore = C901,E402,E501
max-complexity = 10
max-line-length = 160
norecursedirs = {[base]norecursedirs}
[pytest]
markers =
flake8
pylint
deps =
{[testenv:pytest]deps}
python_files = test_*.py
[testenv:flake8]
commands =
pytest -v --cache-clear \
--flake8 \
--junitxml=test-results/pytest-flake8-result.xml \
{posargs}
There is a multitude of packages that declare a dependency on s specific version of configparser (i.e. 'configparser>=3.5'). Removing version form setup.cfg
makes them think that configparser has version 0.0.0 and fail the version check. This problem has started a few days ago presumably with version 4.0.1.
Please restore the version
attribute ASAP!!!
Original report by Laurent LAPORTE (Bitbucket: Tantale, GitHub: Tantale).
Since the purpose of this library is to provide a backport to old Python versions, notably Python 2.7, it could be a good thing to use explicitly unicode string literals in the code sample:
>>> parser = ConfigParser()
>>> parser.read_string(u"""
[DEFAULT]
location = upper left
visible = yes
editable = no
color = blue
[main]
title = Main Menu
color = green
[options]
title = Options
""")
>>> parser['main']['color']
u'green'
>>> parser['main']['editable']
u'no'
>>> section = parser['options']
>>> section['title']
u'Options'
>>> section['title'] = 'Options (editable: %(editable)s)'
>>> section['title']
u'Options (editable: no)'
notice the "u" prefix before quotes.
I've found a problem with how configparser handles bytestrings.
Example:
foo.conf
byte_string = b')]}\',\n'
bar.py
path_conf = os.path.abspath(os.path.join(os.path.dirname( __file__ ),'..', 'conf' + "/" + "foo.conf"))
if os.path.exists(path_conf):
conf_details = configparser.ConfigParser()
byte_string = conf_details.get('config', 'byte_string')
Intended behavior:
byte_string2 = b')]}\',\n'
print(byte_string2) # b")]}',\n"
print(len(byte_string2)) # 6
configparser behavior:
print(byte_string) # b')]}\',\n'
print(len(byte_string)) # 11
Hello,
I try to read dictionary with None value from ConfigParser and I am expecting to have None value in config_parser object but instead of None I have empty string.
from configparser import ConfigParser
config_parser = ConfigParser(allow_no_value=True)
a = {'a': {'b': None}}
config_parser.read_dict(a)
config_parser.items('a') # [('b', '')]
I try to play with ConfigParser and find out that this problem is coming from:
_DEFAULT_INTERPOLATION = BasicInterpolation()
which I also need. If I change default interpolation to:
_DEFAULT_INTERPOLATION = Interpolation()
I don't have problem with None values but I have problems with interpolation.
Appears there is a license file in this repo, but it is missing from the sdist and wheels on PyPI. Would be great if the license file could be included in future releases to aid downstream users and packagers.
Original report by Luca (Bitbucket: McSpritz, GitHub: McSpritz).
Hi,
I've got this error while installing in a virtual env with pycharm (community edition)
It is a syntax error.
#!text
Collecting configparser
Using cached configparser-3.3.0r2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/mcspritz/myPython/lib/python3.5/site-packages/setuptools/__init__.py", line 5, in <module>
import distutils.core
File "/usr/lib/python3.5/distutils/core.py", line 18, in <module>
from distutils.config import PyPIRCCommand
File "/usr/lib/python3.5/distutils/config.py", line 7, in <module>
from configparser import ConfigParser
File "/tmp/pycharm-packaging0.tmp/configparser/configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pycharm-packaging0.tmp/configparser
kind regards
When running tests on Python 2.7, I see these warnings:
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_bytes_new_style
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_exceptions
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_exceptions
/Users/jaraco/code/public/configparser/src/backports/configparser/__init__.py:1294: DeprecationWarning: You passed a bytestring. Implicitly decoding as UTF-8 string. This will not work on Python 3. Please switch to using Unicode strings across the board.
_, key, value = self._parser._validate_value_types(option=key, value=value)
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_bytes_old_style
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_exceptions
/Users/jaraco/code/public/configparser/src/backports/configparser/__init__.py:1243: DeprecationWarning: You passed a bytestring. Implicitly decoding as UTF-8 string. This will not work on Python 3. Please switch to using Unicode strings across the board.
section, _, _ = self._validate_value_types(section=section)
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_bytes_old_style
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_exceptions
src/test_configparser.py::UnicodeBackportTestCase::test_bytes_exceptions
/Users/jaraco/code/public/configparser/src/backports/configparser/__init__.py:1236: DeprecationWarning: You passed a bytestring. Implicitly decoding as UTF-8 string. This will not work on Python 3. Please switch to using Unicode strings across the board.
_, option, value = self._validate_value_types(option=option, value=value)
The tests clearly wish to exercise that legacy behavior. Can we suppress those warnings?
Original report by Buck Brady (Bitbucket: bbrady145, GitHub: Unknown).
the following does not raise a ConfigParser.NoSectionError
#!python
try:
cfg.has_section('Section Name')
except ConfigParser.NoSectionError as err:
exit(1)
The try statment returns that has_section = False
however there is no exception raised.
however the following will raise the NoSectionError
#!python
try:
x = cfg.has_section('Section Name')
if not x:
raise ConfigParser.NoSectionError('Section Name', )
except ConfigParser.NoSectionError as err:
exit(1)
if this is just user error or just me using this incorrectly I apologize.
Original report by Kevin Brown (Bitbucket: kevinbrown, GitHub: kevinbrown).
Right now, only the tar.gz
file is being distributed on PyPI for configparser, which isn't that much of an issue, but it does add some time to installing the package.
This package should be compatible with the Wheel format, considering it doesn't appear to have any C dependencies and it is compatible with both Python 2 and 3. As a result, you should only need to generate a universal wheel and then everyone (on all systems) will get the ability to install configparser with just the wheel, without having to do any extra work.
Original report by Rémy HUBSCHER (Bitbucket: natim, GitHub: natim).
Using configparser-3.5.0b1 I have the following error:
from configparser import ConfigParser, ExtendedInterpolation
ImportError: cannot import name ExtendedInterpolation
The documentation[0] seems to still consider that it should be the way to go.
Do you have any idea of how I should change that?
[0] https://docs.python.org/3/library/configparser.html#customizing-parser-behaviour
Original report by Éric Araujo (Bitbucket: Merwok, GitHub: Merwok).
It’s not recommended to use the same package name for a backort. importlib has importers (which is also a testing bed for new features), logging has logutil (ditto), packaging has distutils2. I suggest you use configparser2.
Original report by Jonathan McCall (Bitbucket: jonnymcc, GitHub: jonnymcc).
The tag 3.3.0r2 is missing. Noticed when trying to install Yelp's ElastAlert Yelp/elastalert#671.
Description from readme / pypi:
This is a backport of those changes so that they can be used directly in Python 2.6 - 3.5
... requirement Python version is set to:
Requires: Python >=3.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.