boostorg / boostorg/python

Conversion of `char` to python is broken in Python >= 3.0

Ouverte
#95 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
537
Forks
223
Merge moyen
11 h 22 min
PR mergées (30 j)
2

Description

`char` is currently being converted using `PyUnicode_FromStringAndSize(&x, 1)`, but [PyUnicode_FromStringAndSize](https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_FromStringAndSize) interprets the input string as UTF-8, so every char between 128 and 255 is a malformed UTF-8 string and can't be converted.

Before submitting a fix, I'd like to discuss the solution: returning a positive integer seems to be more appropriate, since this is the new convention in Python 3 (e.g., `b'a'[0]` returns 97 in Python 3, while it returns `b'a'` in Python 2). Also, this is more consistent with how `signed char` and `unsigned char` are currently converted (as integers too).

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.