giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.32k stars 1.39k forks source link

[Win] "\" as line ending character in __init__.py throws an syntax error #2328

Closed jho101 closed 1 year ago

jho101 commented 1 year ago

Summary

Description

We are synchronizing our python packages with the version control tool Perforce. In Perforce the user can decide between several line ending styles like (local, system, shared(UNIX and local). So the result of it is that the whitespaces in the files are different depending on what line ending style we are using.

The problem here is that every time a "\" is used, script fails. I have attached the correspond file with the not working line endings. If you ressolve the "\" it should work:

init.py.txt

giampaolo commented 1 year ago

I'm not sure what you're trying to say here. psutil uses UNIX line endings (\n) in all files (.py, .rst, etc.).

jho101 commented 1 year ago

Hi, thanks for the quick reply. I wanted to say that if someone changes the line endings to a non Unix style, when psutil is not working anymore because of using the "\" to forwarding the code line to the next line. I think my initial description is misleading. I have added another images. E.g.: If I remove the "\" from the fun variable, when it is working.

image

image

giampaolo commented 1 year ago

A problem with your editor perhaps? I'm not sure. Anyway, if you want to modify psutil source code I recommend configuring your editor to use the UNIX style. You don't want to mix \n and \r\n anyway. Just stick to one (\n).