Closed marko-travelperk closed 3 years ago
I'm not immediately seeing this with Python 3.6.9 – please could you provide more details (exact versions of Python and the library, line number traces, full terminal output etc.)
Closing for now, please re-open if/when repro details become available.
I have the exact same issue, using python 3.6.11, and phonenumbers==7.7.5
Here is a simple code to reproduce:
import warnings
warnings.filterwarnings("error")
from phonenumber_field.modelfields import PhoneNumberField
---------------------------------------------------------------------------
DeprecationWarning Traceback (most recent call last)
<ipython-input-2-0acfdf99daab> in <module>
----> 1 from phonenumber_field.modelfields import PhoneNumberField
~/.virtualenvs/core3/lib/python3.6/site-packages/phonenumber_field/modelfields.py in <module>
4 from django.db import models
5 from django.utils.translation import ugettext_lazy as _
----> 6 from phonenumber_field.validators import validate_international_phonenumber
7 from phonenumber_field import formfields
8 from phonenumber_field.phonenumber import PhoneNumber, to_python, string_types
~/.virtualenvs/core3/lib/python3.6/site-packages/phonenumber_field/validators.py in <module>
5 from django.core.exceptions import ValidationError
6 from django.utils.translation import ugettext_lazy as _
----> 7 from phonenumber_field.phonenumber import to_python
8
9
~/.virtualenvs/core3/lib/python3.6/site-packages/phonenumber_field/phonenumber.py in <module>
2
3 import sys
----> 4 import phonenumbers
5 from django.core import validators
6 from phonenumbers.phonenumberutil import NumberParseException
~/.virtualenvs/core3/lib/python3.6/site-packages/phonenumbers/__init__.py in <module>
131 is_emergency_number,
132 is_carrier_specific)
--> 133 from .phonenumbermatcher import PhoneNumberMatch, PhoneNumberMatcher, Leniency
134
135
~/.virtualenvs/core3/lib/python3.6/site-packages/phonenumbers/phonenumbermatcher.py in <module>
120 _DIGIT_SEQUENCE + u("(?:") + _PUNCTUATION + _DIGIT_SEQUENCE + u(")") + _BLOCK_LIMIT +
121 u("(?:") + _EXTN_PATTERNS_FOR_MATCHING + u(")?"),
--> 122 _REGEX_FLAGS)
123
124 # Matches strings that look like publication pages. Example: "Computing
~/.pyenv/versions/3.6.11/lib/python3.6/re.py in compile(pattern, flags)
231 def compile(pattern, flags=0):
232 "Compile a regular expression pattern, returning a pattern object."
--> 233 return _compile(pattern, flags)
234
235 def purge():
~/.pyenv/versions/3.6.11/lib/python3.6/re.py in _compile(pattern, flags)
299 if not sre_compile.isstring(pattern):
300 raise TypeError("first argument must be string or compiled pattern")
--> 301 p = sre_compile.compile(pattern, flags)
302 if not (flags & DEBUG):
303 if len(_cache) >= _MAXCACHE:
~/.pyenv/versions/3.6.11/lib/python3.6/sre_compile.py in compile(p, flags)
560 if isstring(p):
561 pattern = p
--> 562 p = sre_parse.parse(p, flags)
563 else:
564 pattern = None
~/.pyenv/versions/3.6.11/lib/python3.6/sre_parse.py in parse(str, flags, pattern)
853
854 try:
--> 855 p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
856 except Verbose:
857 # the VERBOSE flag was switched on inside the pattern. to be
~/.pyenv/versions/3.6.11/lib/python3.6/sre_parse.py in _parse_sub(source, state, verbose, nested)
414 while True:
415 itemsappend(_parse(source, state, verbose, nested + 1,
--> 416 not nested and not items))
417 if not sourcematch("|"):
418 break
~/.pyenv/versions/3.6.11/lib/python3.6/sre_parse.py in _parse(source, state, verbose, nested, first)
741 ' (truncated)' if len(source.string) > 20 else '',
742 ),
--> 743 DeprecationWarning, stacklevel=nested + 6
744 )
745 if (state.flags & SRE_FLAG_VERBOSE) and not verbose:
DeprecationWarning: Flags not at the start of the expression '(?:[(\\[([++][-x‐-―−ー' (truncated)
If the version of phonenumbers
involved is indeed 7.7.5, that's nearly 5 years old. Please could you try reproducing with a more recent version of the library (and preferably with just the phonenumbers
library involved, not phonenumber_field
).
Happens every time when I run unit tests that call phonenumbers.match python 3.6, probably
This similar issue has a few recommendations to resolve the same issue https://github.com/gboeing/osmnx/issues/285