Skip to content

cli and lib init regex error: bad escape \s at position 0  #151

@chrisdlangton

Description

@chrisdlangton

The error;

Traceback (most recent call last):
  File "/tmp/.env/lib/python3.7/sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\s'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/.env/bin/pwhois", line 3, in <module>
    import argparse, pythonwhois, json, datetime, sys
  File "/tmp/.env/lib/python3.7/site-packages/pythonwhois/__init__.py", line 1, in <module>
    from . import net, parse
  File "/tmp/.env/lib/python3.7/site-packages/pythonwhois/parse.py", line 363, in <module>
    registrant_regexes = [preprocess_regex(regex) for regex in registrant_regexes]
  File "/tmp/.env/lib/python3.7/site-packages/pythonwhois/parse.py", line 363, in <listcomp>
    registrant_regexes = [preprocess_regex(regex) for regex in registrant_regexes]
  File "/tmp/.env/lib/python3.7/site-packages/pythonwhois/parse.py", line 205, in preprocess_regex
    regex = re.sub(r"\\s\*\(\?P<([^>]+)>\.\+\)", r"\s*(?P<\1>\S.*)", regex)
  File "/tmp/.env/lib/python3.7/re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/tmp/.env/lib/python3.7/re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "/tmp/.env/lib/python3.7/re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/tmp/.env/lib/python3.7/sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \s at position 0

Reproduce;

cd /tmp
virtualenv -p $(which python3) .env
source .env/bin/activate
pip install pythonwhois
pwhois --raw <any domain>

python --version Python 3.7.3
uname -a Linux zhurong 5.0.0-27-generic #28-Ubuntu SMP Tue Aug 20 19:53:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Note: also the same error when using from pythonwhois import get_whois not just the cli executable..

Not sure how to debug this, can't see how I would be the only one effected by this basic usage but based on some quick searches it seems i might be...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions