Skip to content

Formencode validator.py SyntaxError #151

Closed

Description

@golyalpha

When on Windows, there are a few lines with syntax errors in validators.py

> py -m app
Traceback (most recent call last):
  File "C:\Users\golya\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Users\golya\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\Users\golya\AppData\Local\Programs\Python\Python37\Lib\runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\golya\git\tournaments\app\__init__.py", line 10, in <module>
    from . import db
  File "C:\Users\golya\git\tournaments\app\db.py", line 1, in <module>
    from sqlobject.sqlite.sqliteconnection import SQLiteConnection
  File "C:\Users\golya\.virtualenvs\tournaments-O-Cvtk8m\lib\site-packages\sqlobject\__init__.py", line 8, in <module>
    from .col import *  # noqa
  File "C:\Users\golya\.virtualenvs\tournaments-O-Cvtk8m\lib\site-packages\sqlobject\col.py", line 33, in <module>
    from formencode import compound, validators
  File "C:\Users\golya\.virtualenvs\tournaments-O-Cvtk8m\lib\site-packages\formencode\__init__.py", line 9, in <module>
    from formencode import validators
  File "C:\Users\golya\.virtualenvs\tournaments-O-Cvtk8m\lib\site-packages\formencode\validators.py", line 5730

    ^
SyntaxError: invalid syntax

Formencode version: 1.3.1

Activity

  1. andy-maier commented on Feb 2, 2020

    @andy-maier

    I have the same issue with Python 3.7 on Windows.

    After some investigation, I found the following:

    1. The line counting of the reported syntax error is incorrect. If you divide the reported line number by two, you get to the actual line in error (line 2865).
    2. The reason for the syntax error is that on line 2865, the backslash is used for line continuation, but the line ends with 0x0D0D0A which is one 0x0D too much and is not tolerated by the Python on Windows.

    So the root cause seems to be incorrect line ends in formencode/validator.py. This can also be seen when using vim on Windows to look at the file: It displays "^M" at the end of each line, which it does not do when there are regular Windows-style line ends of 0x0D0A.

    This issue exists for (at least) the following files:

    • formencode/validators.py
    • formencode/htmlfill.py

    Note that I look at the pip-installed copies of these files in a virtualenv for this, not at the source files in the repo.

    The strange thing is that these two files have not been updated since 1/2017 and 12/2015, respectively, so I suspect that something else plays a role, in addition.

    I don't have much tooling at hand right now to investigate further, but will do so later today.

  2. drnlm commented on Aug 6, 2020

    @drnlm

    Which release of 3.7 were you seeing this on? This looks a lot like python/cpython#6483 (comment) , which means the issue should only be present with 3.7.0 .

  3. golyalpha commented on Aug 7, 2020

    @golyalpha
    Author

    I'm sorry, it's been over a year, and I currently have no way to easily replicate the issue without writing some code. I may get to it later in the day, but no promises.

  4. drnlm commented on Aug 7, 2020

    @drnlm

    I have verified that I can reproduce this with Python 3.7.0 on windows 10, but not with the current release (3.7.8), so I believe this isn't a formencode bug.

  5. golyalpha commented on Aug 8, 2020

    @golyalpha
    Author

    It's quite possible that is in fact the case. Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions