Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding does not work when using StringIO under Python 2 #196

Open
tkeffer opened this issue Jan 24, 2020 · 4 comments
Open

encoding does not work when using StringIO under Python 2 #196

tkeffer opened this issue Jan 24, 2020 · 4 comments

Comments

@tkeffer
Copy link

tkeffer commented Jan 24, 2020

Consider the following:

Python 2.7.16 (default, Nov  9 2019, 05:55:08) 
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from StringIO import StringIO
>>> import configobj
>>> print(configobj.__version__)
5.0.6
>>> s = StringIO("temperature = 20°C")
>>> c = configobj.ConfigObj(s, encoding='utf-8')
>>> c['temperature']
'20\xc2\xb0C'
>>> type(c['temperature'])
<type 'str'>

Under Python 2, my expectation is that the type would be Unicode, not str.

Or, am I missing something?

@robdennis
Copy link
Member

this is at least unit testable so I'll look into it. At this exact second I don't actually know what the expected result should be.

@tkeffer
Copy link
Author

tkeffer commented Jan 8, 2023

I would expect the resuts to be

>>> c['temperature']
u'20\xb0C'
>>> type(c['temperature'])
<type 'unicode'>

@robdennis
Copy link
Member

This is helpful thank you. I was imprecise and I meant this as also a "I need to remember what the code does when the encoding keyword argument is provided".

Optimistically putting this in 5.1.0 even though it's not clear what options we have for building 2.x distributables

@tkeffer
Copy link
Author

tkeffer commented Jan 9, 2023

It's been over 3 years since Python 2.7 end of life. No one would give you grief if you simply dropped support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants