Skip to content

Bytes, strings, and unicode? #30

Open
@ltratt

Description

@ltratt

I see this warning in the standard library:

/tmp/pygrate2/Lib/codecs.py:506: Py3xWarning: The first string is 'str' while the second is 'unicode': mixed bytes, str and unicode operands cannot be used in string concatenation in Python 3.x: convert the operand(s) so that they are the same type.
  self.charbuffer += newchars

Since Python3 doesn't have the unicode type per se, I'm wondering if this warning is quite right? As I understand the situation (and my memory is a bit fuzzy...):

  • Python2 has the types str and unicode but not a type bytes. The bytes() function returns strs.
  • Python3 has the types bytes and str but not unicode.

If I've got that (roughly) correct, I wonder whether the warning at the top of this issue is correct and/or as accurate as it could be? I think that str + unicode in Python2 will always map to str + str in Python3? Or are there certain types of strings/unicode strings in Python2 that will map to bytes in Python3?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions