FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

tools: fix regex strings in Python tools by josusky · Pull Request #46585 · nodejs/node · GitHub

/ node Public

tools: fix regex strings in Python tools - #46585

Merged
cclauss merged 2 commits into
nodejs:mainfrom
josusky:main
Feb 14, 2023
Merged

tools: fix regex strings in Python tools#46585
cclauss merged 2 commits into
nodejs:mainfrom
josusky:main

Conversation

josusky commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

tools: fix regex strings in Python tools

Strings used to construct regular expressions shall be marked as raw
otherwise newer versions of Python throw "SyntaxError" because of
invalid escape sequences.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/v8-update

nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. post-mortem Issues and PRs related to the post-mortem diagnostics of Node.js. python PRs and issues that require attention from people who are familiar with Python. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency. labels Feb 9, 2023

cjihrig commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

Changes in deps/v8 need to be upstreamed to the V8 project first.

josusky commented Feb 9, 2023

Copy link
Copy Markdown
Contributor Author

OK, so please upstream it, whatever it means ;-)
I am sorry, I am new to nodejs, and I have no idea about the relation to the v8 project. I have just spotted a trivial bug so I have fixed it.

Trott commented Feb 9, 2023

Copy link
Copy Markdown
Member

@nodejs/python

MoLow commented Feb 9, 2023

Copy link
Copy Markdown
Member

OK, so please upstream it, whatever it means ;-) I am sorry, I am new to nodejs, and I have no idea about the relation to the v8 project. I have just spotted a trivial bug so I have fixed it.

@josusky thanks for this contribution, the meaning is you need to get the change into v8 (following their contribution guide), then if the change is accepted it will automatically be pulled into node

Trott commented Feb 9, 2023

Copy link
Copy Markdown
Member

@josusky thanks for this contribution, the meaning is you need to get the change into v8 (following their contribution guide), then if the change is accepted it will automatically be pulled into node

For clarity: That only applies to the change to deps/v8/tools/gen-postmortem-metadata.py. The changes in the other three files can be submitted in this PR.

cclauss commented Feb 10, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

I do not understand the reason for this pull request. Regex loves raw strings in Python. They are recommended in Python docs.

The solution is to use Python’s raw string notation for regular expressions; backslashes are not handled in any special way in a string literal prefixed with 'r', so r"\n" is a two-character string containing '' and 'n', while "\n" is a one-character string containing a newline. Regular expressions will often be written in Python code using this raw string notation. https://docs.python.org/3/howto/regex.html#the-backslash-plague

Why change from one string to another If two strings are equal to each other?
% python3

>>> r'\s*=.*' == '\s*=.*'
True
>>> r'\\s*=.*' == '\\s*=.*'
False

Please provide example code and a stack trace for where each of these raw strings generates a Python SyntaxError.

cclauss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please provide example code and a stack trace for where each of these raw strings generates a Python SyntaxError.

josusky commented Feb 14, 2023

Copy link
Copy Markdown
Contributor Author

The point is that in your code you sometimes do not use raw strings. Just look at the code that I have changed. If your python is old enough or not set to report all errors you may not notice the problem, but sooner or later, the deprecated constructions like '\s' will stop working. Just try the following code:

test_string = '\s'

and run it like this python3 -Werror test.py

  File "/home/jano/test.py", line 1
    test_string = '\s'
                  ^^^^
SyntaxError: invalid escape sequence '\s'

cclauss merged this pull request into nodejs:main Feb 14, 2023

targos commented Feb 14, 2023

Copy link
Copy Markdown
Member

Pull request was landed without a full CI run or metadata in the commit message. I force-pushed main to cancel it. Unfortunately we cannot reopen a merged PR. @josusky can you please open a new one?

josusky commented Feb 14, 2023

Copy link
Copy Markdown
Contributor Author

@targos I am a bit lost. I can certainly create a new PR with the same code change but what should be then the difference to this one?

targos commented Feb 14, 2023

Copy link
Copy Markdown
Member

This one was already merged, so we cannot merge it again.

josusky commented Feb 14, 2023

Copy link
Copy Markdown
Contributor Author

Fair enough, the new PR is #46649

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. post-mortem Issues and PRs related to the post-mortem diagnostics of Node.js. python PRs and issues that require attention from people who are familiar with Python. tools Issues and PRs related to the tools directory. v8 engine Issues and PRs related to the V8 dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL