-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Certain .pyi files are not encoded as UTF-8 in Windows #124897
Comments
I wonder how it happened, as I don't see the problem on trunk right now |
I have no idea. I double-checked the files in the source tree just to ensure that no changes had been made, and I double-checked the encoding (which is set to UTF-8) so it's not from the source files. My guess is it's coming from the process that fills in those files. |
@marovira do you mind sharing the line around the offending characters? As at least on Mac builds all sequences are valid unicode ones import torch
import os
print(torch.__version__)
x=open(os.path.join(os.path.dirname(torch.__file__), "_VF.pyi"), "rb").read()
y=x.decode("utf-8")
print(len(x), len(y)) Does not fail and produces |
Sure. I'll post them after I've had dinner. |
Same here, I can get to a Windows machine but probably after dinner... |
I dug around the file a bit and found where the characters are coming from. In the docstring for
The same issue is present in |
Looking through the PyTorch source code, I think I know what's going on. The docstring comes from
Note the double-quotes around |
Until pytorch/pytorch#124897 is resolved.
Above-mentioned changes were introduced by #58311 and there hasn't been any significant changes to neither But let's fix it two way:
|
Replace `“important”` with `important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of #124897
* CI: Fix macOS build Constraints: - `macos-latest` is now ARM64. - Python 3.11 is the first macOS ARM release available in the action. So, we use macos-13 for older versions and stop unconditionally setting the architecture to x86, so that `macos-latest` uses ARM64 builds. * Pin to PyTorch 2.2.2 on Windows Until pytorch/pytorch#124897 is resolved.
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of #124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Install torch != 2.3.0 in CI until pytorch/pytorch#124897 is fixed
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Wondering if there's some flag for mypy to skip such files. |
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897
Replace `“important”` with `important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of #124897 Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
Replace `“important”` with `"important"` and `Taylor’s` with `Taylor's` Fixes the obvious symptoms of pytorch#124897 Test plan: Download [wheel](https://github.com/pytorch/pytorch/actions/runs/8833051644/artifacts/1447995459) and check that generated VF.pyi does not have any unicode characters by running following command: ``` % python3 -c "x=open('_VF.pyi', encoding='utf-8').read();uc=[(i, x[i]) for i in range(len(x)) if ord(x[i])>127];print(uc);assert(len(uc)==0)" ```
🐛 Describe the bug
On Windows platforms, PyTorch 2.3.0 causes mypy to fail with the following error messages:
Inspecting
_VariableFunctions.pyi
and_VF.pyi
reveals that the files are encoded with Latin1 encoding instead of UTF-8 like the rest of the pyi files. Looking deeper at the contents of the wheel obtained fromhttps://download.pytorch.org/whl/cu121/torch-2.3.0%2Bcu121-cp311-cp311-win_amd64.whl
shows that the files are incorrectly encoded there as well. It is important to note that PyTorch 2.2.2 does not have this problem. It was introduced in 2.3.0.As a workaround, the files can be re-encoded to UTF-8, which allows mypy to work correctly.
Versions
PyTorch version: 2.3.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A
OS: Microsoft Windows 11 Enterprise
GCC version: Could not collect
Clang version: 17.0.1
CMake version: version 3.27.4
Libc version: N/A
Python version: 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.22631-SP0
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1650
Nvidia driver version: 552.22
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
CPU:
Architecture=9
CurrentClockSpeed=4701
DeviceID=CPU0
Family=107
L2CacheSize=12288
L2CacheSpeed=
Manufacturer=AuthenticAMD
MaxClockSpeed=4701
Name=AMD Ryzen 9 7900X 12-Core Processor
ProcessorType=3
Revision=24834
Versions of relevant libraries:
[pip3] mypy==1.10.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] onnx==1.16.0
[pip3] onnxruntime==1.17.3
[pip3] torch==2.3.0+cu121
[pip3] torchvision==0.18.0+cu121
[conda] Could not collect
cc @seemethere @malfet @osalpekar @atalman @ezyang @xuzhao9 @gramster
The text was updated successfully, but these errors were encountered: