Skip to content
Myr

windows python 2 doesn't provide inet_pton

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent ffca68f · Browse files · 1 file+10 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−2 removed

  • other:+10 added−2 removed

1 file+10 added−2 removed

modified:flask/helpers.py+10 added-2 removed
40 unmodified lines
4142from .signals import message_flashed43from .globals import session, _request_ctx_stack, _app_ctx_stack, \44 current_app, request45from ._compat import string_types, text_type45from ._compat import string_types, text_type, PY2464747# sentinel48_missing = object()4950
949 unmodified lines
10001001def is_ip(value):1002 """Determine if the given string is an IP address.10031004 Python 2 on Windows doesn't provide ``inet_pton``, so this only1005 checks IPv4 addresses in that environment.10061007 :param value: value to check1008 :type value: str10091010 :return: True if string is an IP address1011 :rtype: bool1012 """1013 if PY2 and os.name == 'nt':1014 try:1015 socket.inet_aton(value)1016 return True1017 except socket.error:1018 return False10191020 for family in (socket.AF_INET, socket.AF_INET6):1021 try:1022 socket.inet_pton(family, value)
6 unmodified lines