Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5a5d6a10
Commit
5a5d6a10
authored
Apr 25, 2012
by
Brett Cannon
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
8923a4d4
718fbf07
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
238 additions
and
138 deletions
+238
-138
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+7
-0
Lib/test/test_logging.py
Lib/test/test_logging.py
+17
-17
Lib/unittest/case.py
Lib/unittest/case.py
+1
-1
Lib/unittest/test/test_skipping.py
Lib/unittest/test/test_skipping.py
+15
-0
Makefile.pre.in
Makefile.pre.in
+13
-2
Misc/NEWS
Misc/NEWS
+6
-0
Objects/longobject.c
Objects/longobject.c
+2
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+6
-2
Python/importlib.h
Python/importlib.h
+113
-113
Tools/msi/msi.py
Tools/msi/msi.py
+19
-3
Tools/scripts/import_diagnostics.py
Tools/scripts/import_diagnostics.py
+39
-0
No files found.
Lib/importlib/_bootstrap.py
View file @
5a5d6a10
...
...
@@ -6,6 +6,13 @@ such it requires the injection of specific modules and attributes in order to
work. One should use importlib as the public-facing version of this module.
"""
#
# IMPORTANT: Whenever making changes to this module, be sure to run
# a top-level make in order to get the frozen version of the module
# update. Not doing so, will result in the Makefile to fail for
# all others who don't have a ./python around to freeze the module
# in the early stages of compilation.
#
# See importlib._setup() for what is injected into the global namespace.
...
...
Lib/test/test_logging.py
View file @
5a5d6a10
...
...
@@ -593,28 +593,28 @@ class HandlerTest(BaseTest):
pass
time.sleep(0.004 * random.randint(0, 4))
def cleanup(remover, fn, handler):
handler.close()
remover.join()
if os.path.exists(fn):
os.unlink(fn)
del_count = 500
log_count = 500
fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
os.close(fd)
del_count = 1000
log_count = 1000
remover = threading.Thread(target=remove_loop, args=(fn, del_count))
remover.daemon = True
remover.start()
for delay in (False, True):
fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
os.close(fd)
remover = threading.Thread(target=remove_loop, args=(fn, del_count))
remover.daemon = True
remover.start()
h = logging.handlers.WatchedFileHandler(fn, delay=delay)
self.addCleanup(cleanup, remover, fn, h)
f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
h.setFormatter(f)
for _ in range(log_count):
time.sleep(0.005)
r = logging.makeLogRecord({'msg': 'testing' })
h.handle(r)
try:
for _ in range(log_count):
time.sleep(0.005)
r = logging.makeLogRecord({'msg': 'testing' })
h.handle(r)
finally:
h.close()
remover.join()
if os.path.exists(fn):
os.unlink(fn)
class BadStream(object):
...
...
Lib/unittest/case.py
View file @
5a5d6a10
...
...
@@ -61,7 +61,7 @@ def skip(reason):
Unconditionally skip a test.
"""
def
decorator
(
test_item
):
if
not
(
isinstance
(
test_item
,
type
)
and
issubclass
(
test_item
,
TestCase
)
):
if
not
isinstance
(
test_item
,
type
):
@
functools
.
wraps
(
test_item
)
def
skip_wrapper
(
*
args
,
**
kwargs
):
raise
SkipTest
(
reason
)
...
...
Lib/unittest/test/test_skipping.py
View file @
5a5d6a10
...
...
@@ -66,6 +66,21 @@ class Test_TestSkipping(unittest.TestCase):
self
.
assertEqual
(
result
.
skipped
,
[(
test
,
"testing"
)])
self
.
assertEqual
(
record
,
[])
def
test_skip_non_unittest_class
(
self
):
@
unittest
.
skip
(
"testing"
)
class
Mixin
:
def
test_1
(
self
):
record
.
append
(
1
)
class
Foo
(
Mixin
,
unittest
.
TestCase
):
pass
record
=
[]
result
=
unittest
.
TestResult
()
test
=
Foo
(
"test_1"
)
suite
=
unittest
.
TestSuite
([
test
])
suite
.
run
(
result
)
self
.
assertEqual
(
result
.
skipped
,
[(
test
,
"testing"
)])
self
.
assertEqual
(
record
,
[])
def
test_expected_failure
(
self
):
class
Foo
(
unittest
.
TestCase
):
@
unittest
.
expectedFailure
...
...
Makefile.pre.in
View file @
5a5d6a10
...
...
@@ -573,12 +573,23 @@ Modules/Setup: $(srcdir)/Modules/Setup.dist
Modules/_testembed
:
Modules/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
$(LINKCC)
$(PY_LDFLAGS)
$(LINKFORSHARED)
-o
$@
Modules/_testembed.o
$(BLDLIBRARY)
$(LIBS)
$(MODLIBS)
$(SYSLIBS)
$(LDLAST)
############################################################################
# Importlib
Python/importlib.h
:
$(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/freeze_importlib.py
./
$(BUILDPYTHON)
$(srcdir)
/Python/freeze_importlib.py
\
$(srcdir)
/Lib/importlib/_bootstrap.py Python/importlib.h
@
if
test
-f
./
$(BUILDPYTHON)
;
then
\
./
$(BUILDPYTHON)
$(srcdir)
/Python/freeze_importlib.py
\
$(srcdir)
/Lib/importlib/_bootstrap.py Python/importlib.h
;
\
else
\
echo
"----------------------------------------------------------"
;
\
echo
"Python/importlib.h needs to be rebuilt, but no interpreter"
;
\
echo
"is available to do so. Leaving the previous version in"
;
\
echo
"place. You may want to run ''make'' a second time after"
;
\
echo
"this build is complete."
;
\
echo
"----------------------------------------------------------"
;
\
fi
############################################################################
# Special rules for object files
...
...
Misc/NEWS
View file @
5a5d6a10
...
...
@@ -71,6 +71,9 @@ Core and Builtins
Library
-------
- Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a
test class that doesn'
t
inherit
from
TestCase
(
i
.
e
.
a
mixin
).
-
Issue
#
4892
:
multiprocessing
Connections
can
now
be
transferred
over
multiprocessing
Connections
.
Patch
by
Richard
Oudkerk
(
sbt
).
...
...
@@ -186,6 +189,9 @@ Tests
Tools
/
Demos
-------------
-
Issue
#
3561
:
The
Windows
installer
now
has
an
option
,
off
by
default
,
for
placing
the
Python
installation
into
the
system
"Path"
environment
variable
.
-
Issue
#
13165
:
stringbench
is
now
available
in
the
Tools
/
stringbench
folder
.
It
used
to
live
in
its
own
SVN
project
.
...
...
Objects/longobject.c
View file @
5a5d6a10
...
...
@@ -1657,6 +1657,7 @@ long_to_decimal_string(PyObject *aa)
/* check we've counted correctly */
assert
(
p
==
PyUnicode_1BYTE_DATA
(
str
));
assert
(
_PyUnicode_CheckConsistency
(
str
,
1
));
Py_DECREF
(
scratch
);
return
(
PyObject
*
)
str
;
}
...
...
@@ -1761,6 +1762,7 @@ _PyLong_Format(PyObject *aa, int base)
if
(
negative
)
*--
p
=
'-'
;
assert
(
p
==
PyUnicode_1BYTE_DATA
(
v
));
assert
(
_PyUnicode_CheckConsistency
(
v
,
1
));
return
v
;
}
...
...
Objects/unicodeobject.c
View file @
5a5d6a10
...
...
@@ -375,10 +375,13 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
{
Py_ssize_t
i
;
Py_UCS4
maxchar
=
0
;
void
*
data
=
PyUnicode_DATA
(
ascii
);
void
*
data
;
Py_UCS4
ch
;
data
=
PyUnicode_DATA
(
ascii
);
for
(
i
=
0
;
i
<
ascii
->
length
;
i
++
)
{
Py_UCS4
ch
=
PyUnicode_READ
(
kind
,
data
,
i
);
ch
=
PyUnicode_READ
(
kind
,
data
,
i
);
if
(
ch
>
maxchar
)
maxchar
=
ch
;
}
...
...
@@ -398,6 +401,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
assert
(
maxchar
>=
0x10000
);
assert
(
maxchar
<=
MAX_UNICODE
);
}
assert
(
PyUnicode_READ
(
kind
,
data
,
ascii
->
length
)
==
0
);
}
return
1
;
}
...
...
Python/importlib.h
View file @
5a5d6a10
No preview for this file type
Tools/msi/msi.py
View file @
5a5d6a10
...
...
@@ -454,6 +454,10 @@ def add_ui(db):
(
"SetDLLDirToTarget"
,
'DLLDIR=""'
,
751
),
])
# Prepend TARGETDIR to the system path, and remove it on uninstall.
add_data
(
db
,
"Environment"
,
[(
"PathAddition"
,
"=-*Path"
,
"[TARGETDIR];[~]"
,
"REGISTRY.path"
)])
# Execute Sequences
add_data
(
db
,
"InstallExecuteSequence"
,
[(
"InitialTargetDir"
,
'TARGETDIR=""'
,
750
),
...
...
@@ -677,11 +681,11 @@ def add_ui(db):
c
=
features
.
xbutton
(
"Advanced"
,
"Advanced"
,
None
,
0.30
)
c
.
event
(
"SpawnDialog"
,
"AdvancedDlg"
)
c
=
features
.
text
(
"ItemDescription"
,
140
,
180
,
210
,
3
0
,
3
,
c
=
features
.
text
(
"ItemDescription"
,
140
,
180
,
210
,
4
0
,
3
,
"Multiline description of the currently selected item."
)
c
.
mapping
(
"SelectionDescription"
,
"Text"
)
c
=
features
.
text
(
"ItemSize"
,
140
,
2
10
,
210
,
45
,
3
,
c
=
features
.
text
(
"ItemSize"
,
140
,
2
25
,
210
,
33
,
3
,
"The size of the currently selected item."
)
c
.
mapping
(
"SelectionSize"
,
"Text"
)
...
...
@@ -835,7 +839,7 @@ def add_features(db):
# (i.e. additional Python libraries) need to follow the parent feature.
# Features that have no advertisement trigger (e.g. the test suite)
# must not support advertisement
global
default_feature
,
tcltk
,
htmlfiles
,
tools
,
testsuite
,
ext_feature
,
private_crt
global
default_feature
,
tcltk
,
htmlfiles
,
tools
,
testsuite
,
ext_feature
,
private_crt
,
prepend_path
default_feature
=
Feature
(
db
,
"DefaultFeature"
,
"Python"
,
"Python Interpreter and Libraries"
,
1
,
directory
=
"TARGETDIR"
)
...
...
@@ -860,6 +864,15 @@ def add_features(db):
testsuite
=
Feature
(
db
,
"Testsuite"
,
"Test suite"
,
"Python test suite (Lib/test/)"
,
11
,
parent
=
default_feature
,
attributes
=
2
|
8
)
# prepend_path is an additional feature which is to be off by default.
# Since the default level for the above features is 1, this needs to be
# at least level higher.
prepend_path
=
Feature
(
db
,
"PrependPath"
,
"Add python.exe to Path"
,
"Prepend [TARGETDIR] to the system Path variable. "
"This allows you to type 'python' into a command "
"prompt without needing the full path."
,
13
,
parent
=
default_feature
,
attributes
=
2
|
8
,
level
=
2
)
def
extract_msvcr90
():
# Find the redistributable files
...
...
@@ -1146,6 +1159,8 @@ def add_registry(db):
"InstallPath"
),
(
"REGISTRY.doc"
,
msilib
.
gen_uuid
(),
"TARGETDIR"
,
registry_component
,
None
,
"Documentation"
),
(
"REGISTRY.path"
,
msilib
.
gen_uuid
(),
"TARGETDIR"
,
registry_component
,
None
,
None
),
(
"REGISTRY.def"
,
msilib
.
gen_uuid
(),
"TARGETDIR"
,
registry_component
,
None
,
None
)]
+
tcldata
)
# See "FeatureComponents Table".
...
...
@@ -1162,6 +1177,7 @@ def add_registry(db):
add_data
(
db
,
"FeatureComponents"
,
[(
default_feature
.
id
,
"REGISTRY"
),
(
htmlfiles
.
id
,
"REGISTRY.doc"
),
(
prepend_path
.
id
,
"REGISTRY.path"
),
(
ext_feature
.
id
,
"REGISTRY.def"
)]
+
tcldata
)
...
...
Tools/scripts/import_diagnostics.py
0 → 100755
View file @
5a5d6a10
#!/usr/bin/env python3
"""Miscellaneous diagnostics for the import system"""
import
sys
import
argparse
from
pprint
import
pprint
def
_dump_state
(
args
):
print
(
sys
.
version
)
print
(
"sys.path:"
)
pprint
(
sys
.
path
)
print
(
"sys.meta_path"
)
pprint
(
sys
.
meta_path
)
print
(
"sys.path_hooks"
)
pprint
(
sys
.
path_hooks
)
print
(
"sys.path_importer_cache"
)
pprint
(
sys
.
path_importer_cache
)
print
(
"sys.modules:"
)
pprint
(
sys
.
modules
)
COMMANDS
=
(
(
"dump"
,
"Dump import state"
,
_dump_state
),
)
def
_make_parser
():
parser
=
argparse
.
ArgumentParser
()
sub
=
parser
.
add_subparsers
(
title
=
"Commands"
)
for
name
,
description
,
implementation
in
COMMANDS
:
cmd
=
sub
.
add_parser
(
name
,
help
=
description
)
cmd
.
set_defaults
(
command
=
implementation
)
return
parser
def
main
(
args
):
parser
=
_make_parser
()
args
=
parser
.
parse_args
(
args
)
return
args
.
command
(
args
)
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
[
1
:]))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment