[issue38925] Decoding unicode not supported after upd to 2.7.17 [possible pymysql related?]

2019-11-26 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

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 "", 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.

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38925] Decoding unicode not supported after upd to 2.7.17 [possible pymysql related?]

2019-11-26 Thread Sebastian Szwarc


New submission from Sebastian Szwarc :

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 
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

--
components: macOS
files: populateTable.txt
messages: 357537
nosy: Sebastian Szwarc, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: Decoding unicode not supported after upd to 2.7.17 [possible pymysql 
related?]
type: behavior
versions: Python 2.7
Added file: https://bugs.python.org/file48745/populateTable.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com