Commit 361215e
authored
Work around NLTK v3.9.3 regression (#2042)
In NLTK v3.9.3, a new security check was added for the Zip Slip issue:
nltk/nltk#3468
This change unfortunately contained a bug that causes false positive
security errors when packages are downloaded to a symlinked path,
since the new check doesn't use `abspath` vs `realpath` consistently:
nltk/nltk#3509
This causes errors like:
```
-----> Downloading NLTK packages: punkt punkt_tab
<frozen runpy>:128: RuntimeWarning: 'nltk.downloader' found in sys.modules after import of package 'nltk', but prior to execution of 'nltk.downloader'; this may result in unpredictable behaviour
[nltk_data] Downloading package punkt to
[nltk_data] /app/.heroku/python/nltk_data...
[nltk_data] Unzipping tokenizers/punkt.zip.
[nltk_data] Zip Slip blocked: punkt/
Error installing package. Retry? [n/y/e]
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/app/.heroku/python/lib/python3.12/site-packages/nltk/downloader.py", line 2631, in <module>
rv = downloader.download(
^^^^^^^^^^^^^^^^^^^^
File "/app/.heroku/python/lib/python3.12/site-packages/nltk/downloader.py", line 773, in download
choice = input().strip()
^^^^^^^
EOFError: EOF when reading a line
```
See also:
https://github.com/heroku/heroku-buildpack-python/actions/runs/22545824206/job/65308000022#step:5:539
Until upstream fix this regression, we can work around it by always
passing the raw path for Python home instead of the symlinked path.
(We generally prefer using the symlinked path where possible, to
ensure the paths used/displayed match between build time and
run time, given the build directory is different from the run directory.)
Longer term I will be deprecating and that removing support for `nltk.txt`
since it's a Heroku-proprietary invention that's unnecessary given most
users instead either commit the NLTK corpora or use the post_compile
hook feature instead.
Fixes #2037.
GUS-W-21410908.1 parent 96e5bea commit 361215e
3 files changed
+10
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments