diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-10-23 15:02:36 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-10-23 15:02:36 -0400 |
commit | 382cd56772efd92a9fe5ce46623029a04163c8cf (patch) | |
tree | c7f50d1add74e1b87f6e608be93f8a4047b5139c /lib/sqlalchemy/engine/url.py | |
parent | 0e7a82304a15e15f2d9de5202aea6b554af76991 (diff) | |
download | sqlalchemy-382cd56772efd92a9fe5ce46623029a04163c8cf.tar.gz |
- The regexp used by the :func:`.url.make_url` function now parses
ipv6 addresses, e.g. surrounded by brackets. [ticket:2851]
Diffstat (limited to 'lib/sqlalchemy/engine/url.py')
-rw-r--r-- | lib/sqlalchemy/engine/url.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/engine/url.py b/lib/sqlalchemy/engine/url.py index 1f192ae7f..74584b787 100644 --- a/lib/sqlalchemy/engine/url.py +++ b/lib/sqlalchemy/engine/url.py @@ -71,7 +71,10 @@ class URL(object): else util.quote_plus(self.password)) s += "@" if self.host is not None: - s += self.host + if ':' in self.host: + s += "[%s]" % self.host + else: + s += self.host if self.port is not None: s += ':' + str(self.port) if self.database is not None: @@ -170,7 +173,10 @@ def _parse_rfc1738_args(name): (?::(?P<password>[^/]*))? @)? (?: - (?P<host>[^/:]*) + (?: + \[(?P<ipv6host>[^/]+)\] | + (?P<ipv4host>[^/:]+) + )? (?::(?P<port>[^/]*))? )? (?:/(?P<database>.*))? @@ -193,6 +199,9 @@ def _parse_rfc1738_args(name): components['password'] = \ util.unquote_plus(components['password']) + ipv4host = components.pop('ipv4host') + ipv6host = components.pop('ipv6host') + components['host'] = ipv4host or ipv6host name = components.pop('name') return URL(name, **components) else: |