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

patchcheck.py raises SystemError on main #105820

Closed
AlexWaygood opened this issue Jun 15, 2023 · 8 comments
Closed

patchcheck.py raises SystemError on main #105820

AlexWaygood opened this issue Jun 15, 2023 · 8 comments
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@AlexWaygood
Copy link
Member

AlexWaygood commented Jun 15, 2023

Bug report

Following #105801, running python Tools/patchcheck/patchcheck.py now results in SystemError being raised.

To reproduce

  1. Make any change to a .py file, e.g.:
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -19,6 +19,7 @@

 a_global = 'global variable'

+
  1. Run python Tools/patchcheck/patchcheck.py:
C:\Users\alexw\coding\cpython>python Tools/patchcheck/patchcheck.py
Running Release|x64 interpreter...
Getting base branch for PR ... upstream/main
Getting the list of files that have been added/changed ... 1 file
Fixing Python file whitespace ... Traceback (most recent call last):
  File "C:\Users\alexw\coding\cpython\Tools\patchcheck\patchcheck.py", line 325, in <module>
    main()
  File "C:\Users\alexw\coding\cpython\Tools\patchcheck\patchcheck.py", line 293, in main
    normalize_whitespace(python_files)
  File "C:\Users\alexw\coding\cpython\Tools\patchcheck\patchcheck.py", line 35, in call_fxn
    result = fxn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexw\coding\cpython\Tools\patchcheck\patchcheck.py", line 188, in normalize_whitespace
    and reindent.check(os.path.join(SRCDIR, path))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexw\coding\cpython\Tools\patchcheck\reindent.py", line 138, in check
    if r.run():
       ^^^^^^^
  File "C:\Users\alexw\coding\cpython\Tools\patchcheck\reindent.py", line 203, in run
    for _token in tokens:
  File "C:\Users\alexw\coding\cpython\Lib\tokenize.py", line 537, in _generate_tokens_from_c_tokenizer
    for info in it:
SystemError: Negative size passed to PyUnicode_New

This failure was visible on the Azure Pipelines job on the PR FYI: https://dev.azure.com/Python/cpython/_build/results?buildId=130389&view=logs&j=256d7e09-002a-52d7-8661-29ee3960640e&t=3d7276d3-4e8d-5309-55ad-fb0b172d9925

Your environment

Python 3.13.0a0 (heads/main:c5111aec2b, Jun 15 2023, 10:53:37) [MSC v.1932 64 bit (AMD64)] on win32

Linked PRs

@AlexWaygood AlexWaygood added the type-bug An unexpected behavior, bug, or error label Jun 15, 2023
@pablogsal
Copy link
Member

@AlexWaygood
Copy link
Member Author

Unlike the "hypothesis checks on Ubuntu" job, though, Azure Pipelines is incredibly flaky, it fails all the time for random reasons. So it's not realistic to make that one "required" in CI.

@pablogsal
Copy link
Member

So it's not realistic to make that one "required" in CI.

Then we should move the parts we care about to some other check and just remove IMHO because nobody looks at it when merging because is constantly failing.

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Jun 15, 2023

nobody looks at it when merging

"nobody" isn't accurate — I generally check failures to see if they're relevant before merging a PR. But I agree with:

Then we should move the parts we care about to some other check and just remove

And we've actually started doing that already; the new "lint" job in CI is basically meant to be a replacement for patchcheck.py, for example. Personally I don't care about patchcheck.py; I only opened this issue because I worried this might be indicative of other breakages :)

@lysnikolaou lysnikolaou self-assigned this Jun 15, 2023
@pablogsal
Copy link
Member

I only opened this issue because I worried this might be indicative of other breakages

Thanks a lot @AlexWaygood, this is certainly the case and we are investigating. Thanks for all the gray work 🖤

@hugovk
Copy link
Member

hugovk commented Jun 15, 2023

Similarly, see #105823 to remove some duplicated docs building from Azure Pipelines.

@lysnikolaou
Copy link
Contributor

lysnikolaou commented Jun 15, 2023

I don't really know why we're seeng this just now, but git bisecting shows that this is the first bad commit:

9216e69a87d16d871625721ed5a8aa302511f367 is the first bad commit
commit 9216e69a87d16d871625721ed5a8aa302511f367
Author: Pablo Galindo Salgado <Pablogsal@gmail.com>
Date:   Tue May 30 22:43:34 2023 +0100

    gh-105069: Add a readline-like callable to the tokenizer to consume input iteratively (#105070)

The reproducer I used was (the good case):

cpython (2ea34cf) (BISECTING) via C v14.0.3-clang via 🐍 pyenv 3.11.3cat tmp/t.py         
self.assertEqual(f'''{
3
=}''', '\n3\n=3')%                                                                                                                                                                                                                                                                                                                                                                                                                  

cpython (2ea34cf) (BISECTING) via C v14.0.3-clang via 🐍 pyenv 3.11.3 
❯ ./python.exe -m tokenize tmp/t.py
0,0-0,0:            ENCODING       'utf-8'        
1,0-1,4:            NAME           'self'         
1,4-1,5:            OP             '.'            
1,5-1,16:           NAME           'assertEqual'  
1,16-1,17:          OP             '('            
1,17-1,21:          FSTRING_START  "f'''"         
1,21-1,22:          OP             '{'            
1,22-1,23:          NL             '\n'           
2,0-2,1:            NUMBER         '3'            
2,1-2,2:            NL             '\n'           
3,0-3,1:            OP             '='            
3,1-3,2:            OP             '}'            
3,2-3,5:            FSTRING_END    "'''"          
3,5-3,6:            OP             ','            
3,7-3,16:           STRING         "'\\n3\\n=3'"  
3,16-3,17:          OP             ')'            
3,17-3,18:          NEWLINE        '\n'           
4,0-4,0:            ENDMARKER      ''             

I'm working on a fix.

@lysnikolaou
Copy link
Contributor

Fixed.

lysnikolaou added a commit that referenced this issue Jun 15, 2023
…okenizer (GH-105828) (#105832)

(cherry picked from commit d382ad4)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
carljm added a commit to carljm/cpython that referenced this issue Jun 15, 2023
* main: (57 commits)
  pythongh-105831: Fix NEWS blurb from pythongh-105828 (python#105833)
  pythongh-105820: Fix tok_mode expression buffer in file & readline tokenizer (python#105828)
  pythongh-105751, test_ctypes: Remove disabled tests (python#105826)
  pythongh-105821: Use a raw f-string in test_httpservers.py (python#105822)
  pythongh-105751: Remove platform usage in test_ctypes (python#105819)
  pythongh-105751: Reenable disable test_ctypes tests (python#105818)
  pythongh-105751: Remove dead code in test_ctypes (python#105817)
  More reorganisation of the typing docs (python#105787)
  Improve docs for `typing.dataclass_transform` (python#105792)
  pythonGH-89812: Churn `pathlib.Path` test methods (python#105807)
  pythongh-105800: Issue SyntaxWarning in f-strings for invalid escape sequences (python#105801)
  pythongh-105751: Cleanup test_ctypes imports (python#105803)
  pythongh-105481: add HAS_JUMP flag to opcode metadata (python#105791)
  pythongh-105751: test_ctypes avoids the operator module (pythonGH-105797)
  pythongh-105751: test_ctypes: Remove @need_symbol decorator (pythonGH-105798)
  pythongh-104909: Implement conditional stack effects for macros (python#105748)
  pythongh-75905: Remove test_xmlrpc_net: skipped since 2017 (python#105796)
  pythongh-105481: Fix types and a bug for pseudos (python#105788)
  Update DSL docs for cases generator (python#105753)
  pythonGH-77273: Better bytecodes for f-strings (pythonGH-6132)
  ...
gvanrossum pushed a commit to gvanrossum/cpython that referenced this issue Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants