64-bit INTs on 32-bit boxes (where they become longs). Also exploit that
int(str) and long(str) will ignore a trailing newline (saves creating a
new string at the Python level).
pickletester.py: Simulate reading a pickle produced by a 64-bit box.
varnames should list all the local variables (with arguments first).
The XXX_NAME ops typically occur at the module level and assignment
ops should create locals.
(Hard to believe these were never handled before)
Add misc.mangle() that mangles based on the rules in compile.c.
XXX Need to test the corner cases
Update CodeGenerator with a class_name attribute bound to None. If a
particular instance is created within a class scope, the instance's
class_name is bound to that class's name.
Add mangle() method to CodeGenerator that mangles if the class_name
has a class_name in it.
Modify the FunctionCodeGenerator family to handle an extra argument--
the class_name.
Wrap all name ops and attrnames in calls to self.mangle()
Make nested scopes enabled by default
Add is_constant_false() helper so that compiled code and symbols are
consistent with builtin compiler's handling of "if 0:"
Fix doc string handling to be consistent with recent change that
eliminates the doc string from the Module's node attribute.
Add fix to print handling from Evan & Shane.
Track change to visitor api by making "verbose" explicit.
Comment out setting CO_NESTED flag (it's unnecessary in 2.2).
Evan Simpson's fix. And his explanation:
If you defined two nested functions in a row that refer to the
same non-global variable, the second one will be generated as
though the variable were global.
The use of com_node() introduces a lot of extra stack frames, enough
to cause a stack overflow compiling test.test_parser with the standard
interpreter recursionlimit. The com_node() is a convenience function
that hides the dispatch details, but comes at a very high cost. It is
more efficient to dispatch directly in the callers. In these cases,
use lookup_node() and call the dispatched node directly.
Also handle yield_stmt in a way that will work with Python 2.1
(suggested by Shane Hathaway)
Remove _preorder as alias for dispatch and call dispatch directly.
Add an extra optional argument to walk()
XXX Also comment out some code that does debugging prints.
Modify rfc822.formatdate() to always generate English names,
regardless of locale. This is required by RFC 1123.
In open_local_file() of urllib and urllib2, use new formatdate() from
rfc822.
recent classobject.c change. When calling an unbound method with no
instances as first argument, the error message has changed. The
message now contains the class name, but the output text being
compared to is too generic, so skip printing it.
lambda (anonymous functions?), function, xrange, buffer, cell (need to
fill in), and (some) descriptor types.
Also added a new test case for testing repr truncation fixes.
modules and extensions on Windows is now $PREFIX/Lib/site-packages.
Includes backwards compatibility code for pre-2.2 Pythons. Contributed
by Paul Moore.
- file URL now starts with "file://" (standard) rather than "file:"
- new optional argument 'context' to enable()
- repeated variable names don't have their values shown twice
- dotted attributes are shown; missing attributes handled reasonably
- highlight the whole logical line even if it has multiple physical lines
- use nice generator interface to tokenize
- formatting fixed so that it looks good in lynx, links, and w3m too
flag, which specifies external or resource intensive tests to
perform. This is used by test_largefile and test_socket_ssl.
-u/--use takes a comma separated list of flags, currently supported:
largefile, network.
usage(): New function. Note that the semantics of main() have changed
slightly; instead of returning an error code, it raises a
SystemExit (via sys.exit()) with the given error code.
main(): use_large_resources => use_resources
Also, added support for long-option alternative to the short
options.
_expectations: Added test_socket_ssl to the list of expectedly skipped
tests.
requires(): New function which can be used to `assert' that a specific
-u/--use resource flag is present. Raises a TestSkipped if not.
This is used in test_largefile and test_socket_ssl to enable
external or resource consumptive tests that are normally
disabled.
to stdout. Repaired by not printing at all except in verbose mode.
Made the test about 6x faster -- envelope analysis showed it took time
proportional to the square of the # of tasks. Now it's linear.
module has to deal with "class" HTML-as-deployed as well as XHTML, so we
cannot be as strict as XHTML allows.
This closes SF bug #453059, but uses a different fix than suggested in
the bug comments.
right way"). Fiddle __future__.py to use them.
Jeremy's pyassem.py may also want to use them (by-hand duplication of
magic numbers is brittle), but leaving that to his judgment.
Beef up __future__'s test to verify the exported feature names appear
correct.
For the HTTPS class (when available), ensure that the x509 certificate data
gets passed through to the HTTPSConnection class. Create a new
HTTPS.__init__ to do this, and refactor the HTTP.__init__ into a new _setup
method for both init's to call.
Note: this is solved differently from the patch, which advocated a new
**x509 parameter on the base HTTPConnection class. But that would open
HTTPConnection to arbitrary (ignored) parameters, so was not as desirable.
somewhat less horrid hack <wink>: if a module does
from __future__ import X
then the module dict D is left in a state such that (viewing X as a
string)
D[X] is getattr(__future__, X)
So by examining D for all the names of future features, and making that
test for each, we can make a darned good guess as to which future-features
were imported by the module. The appropriate flags are then sucked out
of the __future__ module, and passed on to compile()'s new optional
arguments (PEP 264).
Also gave doctest a meaningful __all__, removed the history of changes
(CVS serves that purpose now), and removed the __version__ vrbl (similarly;
before CVS, it was a reasonable clue, but not anymore).
builtin_eval wasn't merging in the compiler flags from the current frame;
I suppose we never noticed this before because future division is the
first future-feature that can affect expressions (nested_scopes and
generators had only statement-level effects).
specified in the uu header already exists. No additional
workaround is provided since out_file=pathname is a deprecated
interface, so it is better to simply pass a file-like object into
out_file anyway. This closes SF bug #438083.
Use isinstance() tests instead of type comparisons.
#449043 supporting __future__ in simulated shells
in support of PEP 264.
Much has changed from the patch version:
+ Repaired bad hex constant for nested_scopes.
+ Defined symbolic CO_xxx names so global search will find these uses.
+ Made the exported list of feature names explicit, instead of abusing
__all__ for this purpose (and redefined __all__ accordingly).
+ Added gross .compiler_flag verification to test___future__.py, and
reworked it a little to make use of the newly exported explicit list
of feature names.
is pickled as a global must now exist by the name under which it is
pickled, otherwise the pickling fails. Previously, such things would
fail on unpickling, or unpickle as the wrong global object. I'm
hoping that this won't break existing code that is playing tricks with
this.
I need a volunteer to do this for cPickle too.
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
expression. This is needed for certain servers that (in violation of
the standard) don't return the parentheses in the response.
This fixes SF bug #441712 by Henrik Weber (not exactly using his
patch).
when an unbound method of class A is stored as a class variable of
class B, and class B is *not* a subclass of class A, that method
should *not* get bound to B instances.
+ test_compare. While None compares less than anything else, it's not
always the case that None has the smallest id().
+ test_descr. The output of %p (pointer) formats varies across platforms.
In particular, on Windows it doesn't produce a leading "0x".
parameter, but did not. This was found because it can create failures
elsewhere based on the presence of mime.types files in some common locations
the module searches by default.
(I will be writing a test for this module shortly!)
that class should compare the id() of those instances. Add a test
that verifies this. This test currently fails; I believe this is
caused by object.c:2.132 (Patch #424475 by loewis).
attribute. Deleting it, or setting it to a non-dictionary result in a
TypeError. Note that getting it the first time magically initializes
it to an empty dict so that func.__dict__ will always appear to be a
dictionary (never None).
Closes SF bug #446645.
- Remove various 'global' directives and move some global definitions
inside the test functions that use them -- we have nested scopes so
the old hacks using globals are no longer needed.
libraries. This is done by adding a .get_source_files() method,
contributed by Rene Liebscher and slightly modified.
Remove an unused local variable spotted by PyChecker
though 'licence' is still supported for backward-compatibility
(Should I add a warning to get_licence(), or not bother?)
Also fixes an UnboundLocalError noticed by PyChecker
bug #449000, "re.sub(r'\n', ...) broke". This was Fredrik's
suggestion -- he's on vacation and said he wouldn't be able to work on
this until next week.
For local files urllib.py doesn't return the MIME
headers that the documentation says it does:
http://www.python.org/doc/current/lib/module-
urllib.html#l2h-2187 states that "When the method is
local-file, returned headers will include a Date
representing the file's last-modified time, a Content-
Length giving file size, and a Content-Type containing
a guess at the file's type"
But in Python 2.1 the only header that gets returned
is the Content-Type:
>>> import urllib
>>> f = urllib.urlopen("gurk.txt")
>>> f.info().headers
['Content-Type: text/plain\n']
Python's logolike module turtle.py did not display
the turtle except when actually drawing lines.
This patch changes the turtle.py module so that
it displays the turtle at all times when tracing is
on. This is similar to the the way that logo works.
When tracing is off the turtle will not be displayed.
If 'unittest.py' was run from the command line with the name of a test
case class as a parameter, it failed with an ugly error. (Which was a
shame, because the documentation says you can do that.)
The problem was the old 'is the class X that you imported from me the same
as my class X?' gotcha.
This introduces:
- A new operator // that means floor division (the kind of division
where 1/2 is 0).
- The "future division" statement ("from __future__ import division)
which changes the meaning of the / operator to implement "true
division" (where 1/2 is 0.5).
- New overloadable operators __truediv__ and __floordiv__.
- New slots in the PyNumberMethods struct for true and floor division,
new abstract APIs for them, new opcodes, and so on.
I emphasize that without the future division statement, the semantics
of / will remain unchanged until Python 3.0.
Not yet implemented are warnings (default off) when / is used with int
or long arguments.
This has been on display since 7/31 as SF patch #443474.
Flames to /dev/null.
Also fix another bug caught by pychecker-- HTTPError() raised when
redirect limit exceed did not pass an fp object. Had to change method
to keep fp object around until it's certain that the error won't be
raised.
Remove useless line in do_proxy().
attribute values. Just using escape() can (and always has) led to broken
XML being generated. This makes sure it always produces the right thing.
This actually closes SF bug #440351.
break old code (in extreme cases). See SF bug #448153.
Add a new subclass IterableUserDict that has the __iter__ method.
Note that for new projects, unless backwards compatibility with
pre-2.2 Python is required, subclassing 'dictionary' is recommended;
UserDict might become deprecated.
__all__, to indicate these are implied as part of the public API.
IDLE's "Check Module" command uses this, and it broke once already
because the reset_globals() and tokeneater() functions were deleted
when Neil converted this to using the generator API of tokenizer.
(See SF bug #448835.)
starting the test suite proper. If _socket fails to build, that will
make this test fail with an ImportError -- handled by the test harness
as "no such module _socket" -- instead of an AttributeError deep in
CGIHTTPServer.
names of the test methods were not changed from the Zope-standard "check"
names to the Python-standard "test_" names, so the tests were not actually
being run.
Added test of hexadecimal character references as a regression check for
SF bug #445196.
Fix handling of hexadecimal character references (legal in XHTML) so that
they are properly interpreted as character references.
This fixes SF bug #445196.