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:56 -0400 |
| commit | 785e44c48be5a25a71b2f2d4fe5e5219ffcb93a8 (patch) | |
| tree | e93515ffaa709aa4d6d867268ece0c022cdc2858 /lib | |
| parent | 622772b46999561ad2033c8d30ee9b1aff75951b (diff) | |
| download | sqlalchemy-785e44c48be5a25a71b2f2d4fe5e5219ffcb93a8.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')
| -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 b15bfbd52..08b620752 100644 --- a/lib/sqlalchemy/engine/url.py +++ b/lib/sqlalchemy/engine/url.py @@ -71,7 +71,10 @@ class URL(object): else urllib.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: @@ -171,7 +174,10 @@ def _parse_rfc1738_args(name): (?::(?P<password>[^/]*))? @)? (?: - (?P<host>[^/:]*) + (?: + \[(?P<ipv6host>[^/]+)\] | + (?P<ipv4host>[^/:]+) + )? (?::(?P<port>[^/]*))? )? (?:/(?P<database>.*))? @@ -196,6 +202,9 @@ def _parse_rfc1738_args(name): components['password'] = \ urllib.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: |
