Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

[ast27] Fix PyBytes_AS_STRING being called on unicode objects #37

Merged
merged 1 commit into from
Apr 7, 2017

Conversation

ddfisher
Copy link
Collaborator

@ddfisher ddfisher commented Apr 6, 2017

This lets typed_ast run on debug-mode Python. I believe this also a minor correctness fix.

@ddfisher ddfisher merged commit e231f9b into master Apr 7, 2017
@ddfisher ddfisher deleted the fix-unicode-error branch April 7, 2017 00:43
@gvanrossum
Copy link
Member

This doesn't look correct. PyUnicode_AsUTF8String() returns a PyObject *, not a C string (https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUTF8String), so you're casting an object to (char *) which is then treated as a C string by forbidden_check(). So then the latter will always return 1.

The original code used PyBytes_AS_STRING() which does return a C string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants