You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment the parser uses the built-in string strip function (https://github.com/RonnyPfannschmidt/iniconfig/blob/master/iniconfig.py#L134). Nowadays is more and more common that people inadvertently introduce Unicode whitespaces in their configuration. The string strip function does not remove this. When we detect such we should at least warn (especially on the left-hand side), or fail. Failing to strip such characters is never the desired effect, as it effectively generates a new key that visually seems the same leaving the user in confusion of why his config does not work.
@RonnyPfannschmidt what about doing strip as (in case the content read from the file is of type unicode):
>>> from unicodedata import name
>>> import sys
>>> import re
>>> spaces = u''.join(re.findall(r'\s', u''.join(unichr(c) for c in xrange(sys.maxunicode+1)), re.UNICODE))
>>> 'envlist '.strip(spaces)
u'envlist'
>>> name(u'\xA0')
'NO-BREAK SPACE
>>> u'envlist\xA0'.strip(spaces)
u'envlist'
>>>
Activity
RonnyPfannschmidt commentedon Jul 18, 2018
as is iniconfig is not unicode aware, so this one is a really tricky one to fix
its def not on my own roadmap
gaborbernat commentedon Jul 18, 2018
@RonnyPfannschmidt what about doing strip as (in case the content read from the file is of type unicode):
gaborbernat commentedon Jul 18, 2018
An alternative solution would be to try to avoid such configs by either warning when such lines are detected.
RonnyPfannschmidt commentedon Jul 18, 2018
i am fine with any consistent solution - i just don't dont have the time/motivation to do the complete dance of ensuring its consistent
right now iniconfig is not unicode aware and works in terms of native strings and ascii whitespace
note that your example generates the spaces in a pretty expensive manner
devel/py-cbor2: Remove Python 3 support restriction
devel/py-cbor2: Remove Python 3 support restriction
devel/py-cbor2: Remove Python 3 support restriction
devel/py-cbor2: Remove Python 3 support restriction
MFH: r501964 devel/py-cbor2: Remove Python 3 support restriction
MFH: r501964 devel/py-cbor2: Remove Python 3 support restriction
RonnyPfannschmidt commentedon Jan 7, 2023
@gaborbernat with the new release unicode support is in but unicode whitespace is not yet considered
Add strip_section_whitespace parameter to address issue pytest-dev#4
RonnyPfannschmidt commentedon Oct 18, 2025
validated and expanded as part of #70 - pytohn3 str is unicode aware
Add strip_section_whitespace parameter to address issue pytest-dev#4