Skip to content
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

Raw string's scope error #152698

Closed
Binaryify opened this issue Jun 18, 2022 · 4 comments
Closed

Raw string's scope error #152698

Binaryify opened this issue Jun 18, 2022 · 4 comments
Assignees

Comments

@Binaryify
Copy link

Binaryify commented Jun 18, 2022

Environment data

Version: 1.68.1 (Universal)
Commit: 30d9c6c
Date: 2022-06-14T12:52:13.188Z
Electron: 17.4.7
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Darwin arm64 21.4.0

Code Snippet

import re

from cv2 import imread

img = imread(r"paper\cell_b.png")

print(r'paper\cell_b.png' == 'paper\\cell_b.png')

image

r'paper\cell_b.png' == 'paper\\cell_b.png' is evaluated as True in Python.
Raw string has "r" before it, and it means string without backslash escape in Python. It's especially useful for handling paths in Windows.

the origin issue: Binaryify/OneDark-Pro#749

@erictraut
Copy link

This appears to be a bug in the textmate grammar for Python. This grammar is built in to VS Code, not shipped as part of Pylance, which is correctly tokenizing and parsing raw strings. We'll need to work with the VS Code team to get this fixed.

@judej judej transferred this issue from microsoft/pylance-release Jun 20, 2022
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Jun 21, 2022
@jrieken jrieken assigned alexr00 and unassigned jrieken Jun 21, 2022
@alexr00
Copy link
Member

alexr00 commented Jun 21, 2022

@Binaryify and @erictraut I am not a frequent Python user, so please correct me if I've misunderstood something, but I think this is a feature: MagicStack/MagicPython#114 (comment) (that's the repo that VS Code pulls our Python syntax highlighting grammar from).

@alexr00 alexr00 closed this as completed Jun 21, 2022
@Binaryify
Copy link
Author

@Haoyu-UT

@Haoyu-UT
Copy link

@alexr00 Thank you for your comment. I now come to understand that for vscode (and MagicPython) r and R are interpreted differently. I'm sorry for my ignorance.
@Binaryify Thank you for your support. Please kindly close the original issue.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants