From a0d107324d38ab6fc5af4c6fee272e1097f98f49 Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Tue, 15 Apr 2014 03:05:02 -0400 Subject: Closed issue #8931: Make alternate formatting for 'c' raise an exception. Patch by Torsten Landschoff. --- Lib/test/test_types.py | 2 ++ Misc/NEWS | 4 ++++ Python/formatter_unicode.c | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index ec10752..11d9546 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -343,6 +343,8 @@ class TypesTests(unittest.TestCase): self.assertRaises(ValueError, 3 .__format__, ",n") # can't have ',' with 'c' self.assertRaises(ValueError, 3 .__format__, ",c") + # can't have '#' with 'c' + self.assertRaises(ValueError, 3 .__format__, "#c") # ensure that only int and float type specifiers work for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + diff --git a/Misc/NEWS b/Misc/NEWS index 45401d6..a158999 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,10 @@ Core and Builtins replacement fields. It now matches the behavior of str.format() in this regard. Patches by Phil Elson and Ramchandra Apte. +- Issue #8931: Make alternate formatting ('#') for type 'c' raise an + exception. It had no effect, now trying to specify it is an error. + Patch by Torsten Landschoff. + Library ------- diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index e3a8149..056bb76 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -846,6 +846,13 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, " format specifier 'c'"); goto done; } + /* error to request alternate format */ + if (format->alternate) { + PyErr_SetString(PyExc_ValueError, + "Alternate form (#) not allowed with integer" + " format specifier 'c'"); + goto done; + } /* taken from unicodeobject.c formatchar() */ /* Integer input truncated to a character */ -- cgit v0.12 From 1e53f8d9bff9d9a7f6ea27aa0aea9eaca5307cc6 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Tue, 15 Apr 2014 11:18:10 +0100 Subject: Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX. --- Lib/test/test_venv.py | 9 +++++++++ Lib/venv/__init__.py | 13 +++++++++++-- Misc/NEWS | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 1084a99..e13cd8c 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -9,6 +9,7 @@ import ensurepip import os import os.path import shutil +import struct import subprocess import sys import tempfile @@ -87,6 +88,14 @@ class BasicTest(BaseTest): self.isdir(self.bindir) self.isdir(self.include) self.isdir(*self.lib) + # Issue 21197 + p = self.get_env_file('lib64') + conditions = ((struct.calcsize('P') == 8) and (os.name == 'posix') and + (sys.platform != 'darwin')) + if conditions: + self.assertTrue(os.path.islink(p)) + else: + self.assertFalse(os.path.exists(p)) data = self.get_text_file_contents('pyvenv.cfg') if sys.platform == 'darwin' and ('__PYVENV_LAUNCHER__' in os.environ): diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index bbdd911..20dafc0 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -1,7 +1,7 @@ """ Virtual environment (venv) package for Python. Based on PEP 405. -Copyright (C) 2011-2012 Vinay Sajip. +Copyright (C) 2011-2014 Vinay Sajip. Licensed to the PSF under a contributor agreement. usage: python -m venv [-h] [--system-site-packages] [--symlinks] [--clear] @@ -30,6 +30,7 @@ optional arguments: import logging import os import shutil +import struct import subprocess import sys import types @@ -132,10 +133,18 @@ class EnvBuilder: else: binname = 'bin' incpath = 'include' - libpath = os.path.join(env_dir, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages') + libpath = os.path.join(env_dir, 'lib', + 'python%d.%d' % sys.version_info[:2], + 'site-packages') context.inc_path = path = os.path.join(env_dir, incpath) create_if_needed(path) create_if_needed(libpath) + # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX + if ((struct.calcsize('P') == 8) and (os.name == 'posix') and + (sys.platform != 'darwin')): + p = os.path.join(env_dir, 'lib') + link_path = os.path.join(env_dir, 'lib64') + os.symlink(p, link_path) context.bin_path = binpath = os.path.join(env_dir, binname) context.bin_name = binname context.env_exe = os.path.join(binpath, exename) diff --git a/Misc/NEWS b/Misc/NEWS index a158999..26377fe 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -41,6 +41,8 @@ Core and Builtins Library ------- +- Issue #21197: Add lib64 -> lib symlink in venvs on 64-bit non-OS X POSIX. + - Issue #17498: Some SMTP servers disconnect after certain errors, violating strict RFC conformance. Instead of losing the error code when we issue the subsequent RSET, smtplib now returns the error code and defers raising the -- cgit v0.12 From 809f90f36905e7623eb98bf216c078a90a4090bd Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Tue, 15 Apr 2014 13:52:21 +0100 Subject: Reverted 16efa8d27e4c after discussion with Eric. --- Lib/test/test_types.py | 2 -- Misc/NEWS | 4 ---- Python/formatter_unicode.c | 7 ------- 3 files changed, 13 deletions(-) diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index 11d9546..ec10752 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -343,8 +343,6 @@ class TypesTests(unittest.TestCase): self.assertRaises(ValueError, 3 .__format__, ",n") # can't have ',' with 'c' self.assertRaises(ValueError, 3 .__format__, ",c") - # can't have '#' with 'c' - self.assertRaises(ValueError, 3 .__format__, "#c") # ensure that only int and float type specifiers work for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + diff --git a/Misc/NEWS b/Misc/NEWS index 26377fe..271898c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,10 +34,6 @@ Core and Builtins replacement fields. It now matches the behavior of str.format() in this regard. Patches by Phil Elson and Ramchandra Apte. -- Issue #8931: Make alternate formatting ('#') for type 'c' raise an - exception. It had no effect, now trying to specify it is an error. - Patch by Torsten Landschoff. - Library ------- diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 056bb76..e3a8149 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -846,13 +846,6 @@ format_long_internal(PyObject *value, const InternalFormatSpec *format, " format specifier 'c'"); goto done; } - /* error to request alternate format */ - if (format->alternate) { - PyErr_SetString(PyExc_ValueError, - "Alternate form (#) not allowed with integer" - " format specifier 'c'"); - goto done; - } /* taken from unicodeobject.c formatchar() */ /* Integer input truncated to a character */ -- cgit v0.12