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

Problema de encoding ao descompactar mensagens: Unicode strings with encoding declaration are not supported. #282

Open
agrings opened this issue Jul 4, 2023 · 2 comments

Comments

@agrings
Copy link

agrings commented Jul 4, 2023

O pynfe 0.4.3 apresenta problemas com encoding ao descompactar certos xmls :

    conteudo = DescompactaGzip.descompacta(zip_resp)
  File "/usr/local/lib/python3.8/site-packages/pynfe/utils/descompactar.py", line 30, in descompacta
    return etree.fromstring(descompactado)
  File "src/lxml/etree.pyx", line 3257, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1911, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

O problema pode ser contornado fazendo a seguinte alteração no "descompactar.py":

        descompactado = texto.decode('utf-8').encode()
        return etree.fromstring(descompactado)
@leogregianin
Copy link
Collaborator

@agrings seria interessante fazer um pull request.
Consegue fazer um PR simulando a situação em um teste unitário?

@felps-dev
Copy link
Collaborator

@agrings consegue fazer como o @leogregianin mencionou? Seria de bastante utilidade para nós e outros utilizadores do projeto.

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

3 participants