This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Decoding unicode not supported after upd to 2.7.17 [possible pymysql related?]
Type: behavior Stage: resolved
Components: macOS Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Sebastian Szwarc, ned.deily, ronaldoussoren, steven.daprano
Priority: normal Keywords:

Created on 2019-11-26 22:45 by Sebastian Szwarc, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
populateTable.txt Sebastian Szwarc, 2019-11-26 22:45
Messages (2)
msg357537 - (view) Author: Sebastian Szwarc (Sebastian Szwarc) Date: 2019-11-26 22:45
As follow up to my recent bug error regarding segmentation fault.
Installed 2.7.17 on Mojave.
Because MySQLdb for reason unknown (SSL required error) is impossible to install by PIP I used PyMysql and modified line as `import pymysql as MySQLdb`

There is no segmentation fault for now (what indicates there can be bug in older python interpreter) but:
the following line worked fine for 2+ years:

colVals = unicode(", ".join(stringList), 'utf-8')

however now I got the error:
2019-11-26 23:25:55,273 [INFO]: Beginning incremental ingest of epf_video_price (200589 records)
Traceback (most recent call last):
  File "EPFImporter2.py", line 453, in <module>
    main()
  File "EPFImporter2.py", line 436, in main
    fieldDelim=fieldSep)
  File "EPFImporter2.py", line 221, in doImport
    ing.ingest(skipKeyViolators=skipKeyViolators)
  File "/Users/sebastian/Documents/test2/EPFIngester.py", line 111, in ingest
    self.ingestIncremental(skipKeyViolators=skipKeyViolators)
  File "/Users/sebastian/Documents/test2/EPFIngester.py", line 206, in ingestIncremental
    skipKeyViolators=skipKeyViolators)
  File "/Users/sebastian/Documents/test2/EPFIngester.py", line 375, in _populateTable
    colVals = unicode(", ".join(stringList), 'utf-8')
TypeError: decoding Unicode is not supported

So the questions:
1. why decoding Unicode is not supported if previously was and worked fine?
2. is it python thing or some pymysql enforcing rules ?


For reference I attached populateTable function
msg357539 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2019-11-26 23:33
Hi Sebastian,

It will help if you do some minimal debugging before reporting what you think is a bug. Also, you should report what version you are upgrading from, not just the version you have upgraded to.

It may help you to provide better bug reports if you read this: http://sscce.org/

"Dcoding unicode" does not make sense and never did, and hasn't been supported since since at least version 2.4:

    py> unicode(u'a', 'uft-8')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    TypeError: decoding Unicode is not supported

One *encodes* Unicode to bytes, and *decodes* bytes to Unicode.

What I believe is happening is that somewhere, somehow, your ``stringList`` variable has a Unicode string object in it, rather than all byte-strings. Calling `', '.join(stringList)` returns a Unicode string if any item in the list is Unicode.

I'm closing this as "Not a bug" as it is not a bug in the language.
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83106
2019-11-26 23:33:45steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg357539

resolution: not a bug
stage: resolved
2019-11-26 22:45:32Sebastian Szwarccreate