-
-
Notifications
You must be signed in to change notification settings - Fork 54
Module load fails with Python 3.9.8 (undefined symbol _PyUnicode_DecodeUnicodeEscape) #169
Comments
For others who may find this in a search, I ran into this problem via black because I had black pinned to an older version. The current version of black appears to no longer use typed-ast and thus won't encounter this issue. |
diff --git a/ast3/Python/ast.c b/ast3/Python/ast.c
index cfca73f..93da89c 100644
--- a/ast3/Python/ast.c
+++ b/ast3/Python/ast.c
@@ -56,6 +56,8 @@ _PyBytes_DecodeEscape(const char *s,
return PyBytes_DecodeEscape(s, len, errors, unicode, recode_encoding);
}
+#endif
+
PyObject *
_PyUnicode_DecodeUnicodeEscape(const char *s,
Py_ssize_t size,
@@ -66,7 +68,6 @@ _PyUnicode_DecodeUnicodeEscape(const char *s,
return PyUnicode_DecodeUnicodeEscape(s, size, errors);
}
-#endif
static int validate_stmts(asdl_seq *);
static int validate_exprs(asdl_seq *, expr_context_ty, int); This seems to get the job done. |
I actually encountered this problem not while running black, but while running pytype. So what's the fix? Is there one? |
ImportError: /home/runner/.cache/pre-commit/repob3mj_5qk/py_env-python3/lib/python3.9/site-packages/typed_ast/_ast3.cpython-39-x86_64-linux-gnu.so: undefined symbol: _PyUnicode_DecodeUnicodeEscape The original issue is python/typed_ast#169
It looks like both mypy and black previously used typed-ast and no longer do. black at least (I haven't checked mypy) has switched to using the |
The last workaround is using |
Thanks for reporting, @hroncok are you willing to make a PR? |
Here you go #171 |
Specifically, when running on Python 3.8 and later, black / mypy will only use typed-ast to check / format Python 2 code. Recent releases of black / mypy have made Python 2 support an "extra", so they no longer install typed-ast on Python 3.8+ unless you do e.g. I'm not sure what exactly pytype's usage of typed-ast looks like, but I imagine it could do something similar. Later today I'll make a release with a fix (thanks to hroncok!), in which case the solution will be to install that newly released typed-ast. |
Many thanks for the quick fix! I have no idea what exactly pytype does with typed_ast, hopefully they will be able to sort it out like black and mypy have. |
Thanks for the fix! Do you have an ETA on when a release with this change might hit pypi? Not asking for any commitment, but I'm currently deciding whether or not to move to the latest black. If you're likely to release soon then I need not bother! :-) |
I believe @hauntsaninja wanted to do a release. If they have other commitments, I will see whether I can do a release today. |
That's fantastic, thank you. I've migrated one repo to the latest black, but this means I can leave the rest alone, since I don't think we need to do any other 3.9 builds imminently. |
Released typed-ast 1.5.0 which includes this fix |
…yped_ast#169). PiperOrigin-RevId: 409928141 Change-Id: If4d6544047cccfe3014d3cde954973eed20cd422
Associated issue: python/typed_ast#169 (comment)
MSYS2 recently updated Python to 3.9.10 which triggered a build issued present in typed_ast, which was fixed in typed_ast 1.5.0: python/typed_ast#169 The currently used mypy version has an upper limit on typed_ast, so this fixed version wasn't pulled in. To fix this, update mypy, fix one new warning it complains about (namedtuple not being named after the variable), and install the markdown stubs explicitely, since mypy no longer bundles them.
typed-ast has an [issue](python/typed_ast#169 (comment)) which will lead to error: undefined symbol _PyUnicode_DecodeUnicodeEscape They fix this error in `1.5.0`, so here comes the update.
typed-ast has an [issue](python/typed_ast#169 (comment)) which will lead to error: undefined symbol _PyUnicode_DecodeUnicodeEscape They fix this error in `1.5.0`, so here comes the update.
Black fails in CI: ``` Creating nhsx-website_test_run ... done Traceback (most recent call last): ... File "/usr/lib/python3.9/site-packages/black/__init__.py", line 52, in <module> from typed_ast import ast3, ast27 File "/usr/lib/python3.9/site-packages/typed_ast/ast3.py", line 40, in <module> from typed_ast import _ast3 ImportError: Error relocating /usr/lib/python3.9/site-packages/typed_ast/_ast3.cpython-39-x86_64-linux-musl.so: _PyUnicode_DecodeUnicodeEscape: symbol not found ``` https://stackoverflow.com/questions/69912264/python-3-9-8-fails-using-black-and-importing-typed-ast-ast3 python/typed_ast#169 (comment)
Attempting to import the module as installed from PyPI (x86_64 architecture) on Python 3.9.8 produces the following exception:
This appears to have broken between Python 3.9.7 and Python 3.9.8.
The text was updated successfully, but these errors were encountered: