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

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

Open
chrisdlangton opened this issue Sep 6, 2019 · 3 comments
Open

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

chrisdlangton opened this issue Sep 6, 2019 · 3 comments

Comments

@chrisdlangton
Copy link

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...

@chrisdlangton
Copy link
Author

the last version this library worked was pythonwhois==2.2.2

@eyupakpinar
Copy link

pip3 install pythonwhois==2.2.2

@yaoyi2008
Copy link

I solved it in this way

path/to/pythonwhois/parse.py

Change

import re, sys, datetime, csv, pkgutil

into

import sys, datetime, csv, pkgutil
import regex as re

Rerun, if prompted that the regex module cannot be found, install it

pip install regex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants