Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 960cf0f

Browse files
committed
Merged revisions 68167,68276,68292-68293,68344 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r68167 | vinay.sajip | 2009-01-02 12:53:04 -0600 (Fri, 02 Jan 2009) | 1 line Minor documentation changes relating to NullHandler, the module used for handlers and references to ConfigParser. ........ r68276 | tarek.ziade | 2009-01-03 18:04:49 -0600 (Sat, 03 Jan 2009) | 1 line fixed #1702551: distutils sdist was not pruning VCS directories under win32 ........ r68292 | skip.montanaro | 2009-01-04 04:36:58 -0600 (Sun, 04 Jan 2009) | 3 lines If user configures --without-gcc give preference to $CC instead of blindly assuming the compiler will be "cc". ........ r68293 | tarek.ziade | 2009-01-04 04:37:52 -0600 (Sun, 04 Jan 2009) | 1 line using clearer syntax ........ r68344 | marc-andre.lemburg | 2009-01-05 13:43:35 -0600 (Mon, 05 Jan 2009) | 7 lines Fix #4846 (Py_UNICODE_ISSPACE causes linker error) by moving the declaration into the extern "C" section. Add a few more comments and apply some minor edits to make the file contents fit the original structure again. ........
1 parent 3563153 commit 960cf0f

5 files changed

Lines changed: 171 additions & 29 deletions

File tree

Doc/library/logging.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,11 +1608,15 @@ for use by library developers.
16081608

16091609
This method does nothing.
16101610

1611+
1612+
16111613
WatchedFileHandler
16121614
^^^^^^^^^^^^^^^^^^
16131615

16141616
.. module:: logging.handlers
16151617

1618+
.. module:: logging.handlers
1619+
16161620
The :class:`WatchedFileHandler` class, located in the :mod:`logging.handlers`
16171621
module, is a :class:`FileHandler` which watches the file it is logging to. If
16181622
the file changes, it is closed and reopened using the file name.
@@ -2286,7 +2290,7 @@ in :mod:`logging` itself) and defining handlers which are declared either in
22862290
.. function:: fileConfig(fname[, defaults])
22872291

22882292
Reads the logging configuration from a :mod:`configparser`\-format file named
2289-
*fname*. This function can be called several times from an application,
2293+
*fname*. This function can be called several times from an application,
22902294
allowing an end user the ability to select from various pre-canned
22912295
configurations (if the developer provides a mechanism to present the choices
22922296
and load the chosen configuration). Defaults to be passed to the ConfigParser
@@ -2320,20 +2324,18 @@ in :mod:`logging` itself) and defining handlers which are declared either in
23202324
Configuration file format
23212325
^^^^^^^^^^^^^^^^^^^^^^^^^
23222326

2323-
The configuration file format understood by :func:`fileConfig` is
2324-
based on :mod:`configparser` functionality. The file must contain
2325-
sections called ``[loggers]``, ``[handlers]`` and ``[formatters]``
2326-
which identify by name the entities of each type which are defined in
2327-
the file. For each such entity, there is a separate section which
2328-
identifies how that entity is configured. Thus, for a logger named
2329-
``log01`` in the ``[loggers]`` section, the relevant configuration
2330-
details are held in a section ``[logger_log01]``. Similarly, a handler
2331-
called ``hand01`` in the ``[handlers]`` section will have its
2332-
configuration held in a section called ``[handler_hand01]``, while a
2333-
formatter called ``form01`` in the ``[formatters]`` section will have
2334-
its configuration specified in a section called
2335-
``[formatter_form01]``. The root logger configuration must be
2336-
specified in a section called ``[logger_root]``.
2327+
The configuration file format understood by :func:`fileConfig` is based on
2328+
:mod:`configparser` functionality. The file must contain sections called
2329+
``[loggers]``, ``[handlers]`` and ``[formatters]`` which identify by name the
2330+
entities of each type which are defined in the file. For each such entity, there
2331+
is a separate section which identifies how that entity is configured. Thus, for
2332+
a logger named ``log01`` in the ``[loggers]`` section, the relevant
2333+
configuration details are held in a section ``[logger_log01]``. Similarly, a
2334+
handler called ``hand01`` in the ``[handlers]`` section will have its
2335+
configuration held in a section called ``[handler_hand01]``, while a formatter
2336+
called ``form01`` in the ``[formatters]`` section will have its configuration
2337+
specified in a section called ``[formatter_form01]``. The root logger
2338+
configuration must be specified in a section called ``[logger_root]``.
23372339

23382340
Examples of these sections in the file are given below. ::
23392341

Include/unicodeobject.h

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ typedef unsigned int Py_UCS4;
126126
typedef unsigned long Py_UCS4;
127127
#endif
128128

129+
/* Py_UNICODE is the native Unicode storage format (code unit) used by
130+
Python and represents a single Unicode element in the Unicode
131+
type. */
132+
129133
typedef PY_UNICODE_TYPE Py_UNICODE;
130134

131135
/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
@@ -369,12 +373,12 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
369373

370374
#else
371375

372-
/* Since splitting on whitespace is an important use case, and whitespace
373-
in most situations is solely ASCII whitespace, we optimize for the common
374-
case by using a quick look-up table with an inlined check.
375-
*/
376-
PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
376+
/* Since splitting on whitespace is an important use case, and
377+
whitespace in most situations is solely ASCII whitespace, we
378+
optimize for the common case by using a quick look-up table
379+
_Py_ascii_whitespace (see below) with an inlined check.
377380
381+
*/
378382
#define Py_UNICODE_ISSPACE(ch) \
379383
((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
380384

@@ -409,13 +413,14 @@ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
409413
#define Py_UNICODE_COPY(target, source, length) \
410414
Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE))
411415

412-
#define Py_UNICODE_FILL(target, value, length) do\
413-
{Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
416+
#define Py_UNICODE_FILL(target, value, length) \
417+
do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
414418
for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\
415419
} while (0)
416420

417-
/* check if substring matches at given offset. the offset must be
421+
/* Check if substring matches at given offset. the offset must be
418422
valid, and the substring must not be empty */
423+
419424
#define Py_UNICODE_MATCH(string, offset, substring) \
420425
((*((string)->str + (offset)) == *((substring)->str)) && \
421426
((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
@@ -425,8 +430,6 @@ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
425430
extern "C" {
426431
#endif
427432

428-
PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
429-
430433
/* --- Unicode Type ------------------------------------------------------- */
431434

432435
typedef struct {
@@ -641,6 +644,17 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
641644

642645
PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal);
643646

647+
/* --- Free-list management ----------------------------------------------- */
648+
649+
/* Clear the free list used by the Unicode implementation.
650+
651+
This can be used to release memory used for objects on the free
652+
list back to the Python memory allocator.
653+
654+
*/
655+
656+
PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
657+
644658
/* === Builtin Codecs =====================================================
645659
646660
Many of these APIs take two arguments encoding and errors. These
@@ -1477,6 +1491,10 @@ PyAPI_FUNC(int) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
14771491

14781492
/* === Characters Type APIs =============================================== */
14791493

1494+
/* Helper array used by Py_UNICODE_ISSPACE(). */
1495+
1496+
PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
1497+
14801498
/* These should not be used directly. Use the Py_UNICODE_IS* and
14811499
Py_UNICODE_TO* macros instead.
14821500

Lib/distutils/command/sdist.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
__revision__ = "$Id$"
66

7-
import sys, os
7+
import os
8+
import string
9+
import sys
10+
from types import *
811
from glob import glob
912
from distutils.core import Command
1013
from distutils import dir_util, dep_util, file_util, archive_util
@@ -332,9 +335,18 @@ def prune_file_list(self):
332335

333336
self.filelist.exclude_pattern(None, prefix=build.build_base)
334337
self.filelist.exclude_pattern(None, prefix=base_dir)
335-
self.filelist.exclude_pattern(r'(^|/)(RCS|CVS|\.svn|\.hg|\.git|\.bzr|_darcs)/.*', is_regex=1)
336338

337-
def write_manifest(self):
339+
if sys.platform == 'win32':
340+
seps = r'/|\\'
341+
else:
342+
seps = '/'
343+
344+
vcs_dirs = ['RCS', 'CVS', r'\.svn', r'\.hg', r'\.git', r'\.bzr',
345+
'_darcs']
346+
vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps)
347+
self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
348+
349+
def write_manifest (self):
338350
"""Write the file list in 'self.filelist' (presumably as filled in
339351
by 'add_defaults()' and 'read_template()') to the manifest file
340352
named by 'self.manifest'.

Lib/distutils/tests/test_sdist.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
"""Tests for distutils.command.sdist."""
2+
import os
3+
import unittest
4+
import shutil
5+
import zipfile
6+
from os.path import join
7+
8+
from distutils.command.sdist import sdist
9+
from distutils.core import Distribution
10+
from distutils.tests.test_config import PyPIRCCommandTestCase
11+
12+
CURDIR = os.path.dirname(__file__)
13+
TEMP_PKG = join(CURDIR, 'temppkg')
14+
15+
SETUP_PY = """
16+
from distutils.core import setup
17+
import somecode
18+
19+
setup(name='fake')
20+
"""
21+
22+
MANIFEST_IN = """
23+
recursive-include somecode *
24+
"""
25+
26+
class sdistTestCase(PyPIRCCommandTestCase):
27+
28+
def setUp(self):
29+
PyPIRCCommandTestCase.setUp(self)
30+
self.old_path = os.getcwd()
31+
32+
def tearDown(self):
33+
os.chdir(self.old_path)
34+
if os.path.exists(TEMP_PKG):
35+
shutil.rmtree(TEMP_PKG)
36+
PyPIRCCommandTestCase.tearDown(self)
37+
38+
def _write(self, path, content):
39+
f = open(path, 'w')
40+
try:
41+
f.write(content)
42+
finally:
43+
f.close()
44+
45+
def test_prune_file_list(self):
46+
# this test creates a package with some vcs dirs in it
47+
# and launch sdist to make sure they get pruned
48+
# on all systems
49+
if not os.path.exists(TEMP_PKG):
50+
os.mkdir(TEMP_PKG)
51+
os.mkdir(join(TEMP_PKG, 'somecode'))
52+
53+
# creating a MANIFEST, a package, and a README
54+
self._write(join(TEMP_PKG, 'MANIFEST.in'), MANIFEST_IN)
55+
self._write(join(TEMP_PKG, 'README'), 'xxx')
56+
self._write(join(TEMP_PKG, 'somecode', '__init__.py'), '#')
57+
self._write(join(TEMP_PKG, 'setup.py'), SETUP_PY)
58+
59+
# creating VCS directories with some files in them
60+
os.mkdir(join(TEMP_PKG, 'somecode', '.svn'))
61+
self._write(join(TEMP_PKG, 'somecode', '.svn', 'ok.py'), 'xxx')
62+
63+
os.mkdir(join(TEMP_PKG, 'somecode', '.hg'))
64+
self._write(join(TEMP_PKG, 'somecode', '.hg',
65+
'ok'), 'xxx')
66+
67+
os.mkdir(join(TEMP_PKG, 'somecode', '.git'))
68+
self._write(join(TEMP_PKG, 'somecode', '.git',
69+
'ok'), 'xxx')
70+
71+
os.chdir(TEMP_PKG)
72+
73+
# now building a sdist
74+
dist = Distribution()
75+
dist.script_name = 'setup.py'
76+
dist.metadata.name = 'fake'
77+
dist.metadata.version = '1.0'
78+
dist.metadata.url = 'http://xxx'
79+
dist.metadata.author = dist.metadata.author_email = 'xxx'
80+
dist.packages = ['somecode']
81+
dist.include_package_data = True
82+
cmd = sdist(dist)
83+
cmd.manifest = 'MANIFEST'
84+
cmd.template = 'MANIFEST.in'
85+
cmd.dist_dir = 'dist'
86+
87+
# zip is available universally
88+
# (tar might not be installed under win32)
89+
cmd.formats = ['zip']
90+
cmd.run()
91+
92+
# now let's check what we have
93+
dist_folder = join(TEMP_PKG, 'dist')
94+
files = os.listdir(dist_folder)
95+
self.assertEquals(files, ['fake-1.0.zip'])
96+
97+
zip_file = zipfile.ZipFile(join(dist_folder, 'fake-1.0.zip'))
98+
try:
99+
content = zip_file.namelist()
100+
finally:
101+
zip_file.close()
102+
103+
# making sure everything has been pruned correctly
104+
self.assertEquals(len(content), 4)
105+
106+
def test_suite():
107+
return unittest.makeSuite(sdistTestCase)
108+
109+
if __name__ == "__main__":
110+
unittest.main(defaultTest="test_suite")

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ AC_ARG_WITH(gcc,
387387
AC_HELP_STRING(--without-gcc,never use gcc),
388388
[
389389
case $withval in
390-
no) CC=cc
390+
no) CC=${CC:-cc}
391391
without_gcc=yes;;
392392
yes) CC=gcc
393393
without_gcc=no;;

0 commit comments

Comments
 (0)