Mercurial > cpython-lru_cache-weakref
annotate Python/sysmodule.c @ 41554:06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r53954 | jeremy.hylton | 2007-02-26 10:41:18 -0800 (Mon, 26 Feb 2007) | 10 lines
Do not copy free variables to locals in class namespaces.
Fixes bug 1569356, but at the cost of a minor incompatibility in
locals(). Add test that verifies that the class namespace is not
polluted. Also clarify the behavior in the library docs.
Along the way, cleaned up the dict_to_map and map_to_dict
implementations and added some comments that explain what they do.
........
r53955 | jeremy.hylton | 2007-02-26 11:00:20 -0800 (Mon, 26 Feb 2007) | 2 lines
Fix assertion.
........
r53969 | neal.norwitz | 2007-02-26 14:41:45 -0800 (Mon, 26 Feb 2007) | 3 lines
When printing an unraisable error, don't print exceptions. before the name.
This duplicates the behavior whening normally printing exceptions.
........
r53970 | andrew.kuchling | 2007-02-26 15:02:47 -0800 (Mon, 26 Feb 2007) | 1 line
Markup fix
........
r53975 | neal.norwitz | 2007-02-26 15:48:27 -0800 (Mon, 26 Feb 2007) | 3 lines
SF #1669182, 2.5 was already fixed. Just assert in 2.6 since string exceptions
are gone.
........
r53976 | andrew.kuchling | 2007-02-26 15:54:17 -0800 (Mon, 26 Feb 2007) | 1 line
Add some items
........
r53981 | jeremy.hylton | 2007-02-26 17:01:59 -0800 (Mon, 26 Feb 2007) | 4 lines
Fix long-standing bug in name mangling for package imports
Reported by Mike Verdone.
........
r53993 | jeremy.hylton | 2007-02-27 08:00:06 -0800 (Tue, 27 Feb 2007) | 2 lines
tabify
........
r53994 | jeremy.hylton | 2007-02-27 08:13:23 -0800 (Tue, 27 Feb 2007) | 5 lines
tabify
Note that ast.c still has a mix of tabs and spaces, because it
attempts to use four-space indents for more of the new code.
........
r53996 | jeremy.hylton | 2007-02-27 09:24:48 -0800 (Tue, 27 Feb 2007) | 2 lines
whitespace normalization
........
r53997 | jeremy.hylton | 2007-02-27 10:29:45 -0800 (Tue, 27 Feb 2007) | 24 lines
Add checking for a number of metaclass error conditions.
We add some new rules that are required for preserving internal
invariants of types.
1. If type (or a subclass of type) appears in bases, it must appear
before any non-type bases. If a non-type base (like a regular
new-style class) occurred first, it could trick type into
allocating the new class an __dict__ which must be impossible.
2. There are several checks that are made of bases when creating a
type. Those checks are now repeated when assigning to __bases__.
We also add the restriction that assignment to __bases__ may not
change the metaclass of the type.
Add new tests for these cases and for a few other oddball errors that
were no previously tested. Remove a crasher test that was fixed.
Also some internal refactoring: Extract the code to find the most
derived metaclass of a type and its bases. It is now needed in two
places. Rewrite the TypeError checks in test_descr to use doctest.
The tests now clearly show what exception they expect to see.
........
r53998 | jeremy.hylton | 2007-02-27 10:33:31 -0800 (Tue, 27 Feb 2007) | 2 lines
Add news about changes to metaclasses and __bases__ error checking.
........
r54016 | armin.rigo | 2007-02-28 01:25:29 -0800 (Wed, 28 Feb 2007) | 3 lines
Modify the segfaulting example to show why r53997 is not a solution to
it.
........
r54022 | brett.cannon | 2007-02-28 10:15:00 -0800 (Wed, 28 Feb 2007) | 2 lines
Add a test for instantiating SyntaxError with no arguments.
........
r54026 | raymond.hettinger | 2007-02-28 10:27:41 -0800 (Wed, 28 Feb 2007) | 1 line
Docstring nit.
........
r54033 | raymond.hettinger | 2007-02-28 10:37:52 -0800 (Wed, 28 Feb 2007) | 1 line
Prepare collections module for pure python code entries.
........
r54053 | raymond.hettinger | 2007-02-28 22:16:43 -0800 (Wed, 28 Feb 2007) | 1 line
Add collections.NamedTuple
........
r54054 | neal.norwitz | 2007-02-28 23:04:41 -0800 (Wed, 28 Feb 2007) | 1 line
Add Pat and Eric for work on PEP 3101 in the sandbox
........
r54061 | andrew.kuchling | 2007-03-01 06:36:12 -0800 (Thu, 01 Mar 2007) | 1 line
Add NamedTuple
........
r54080 | georg.brandl | 2007-03-02 06:37:12 -0800 (Fri, 02 Mar 2007) | 2 lines
Bug #1628895: some better tries to find HTML documentation in pydoc.
........
r54086 | raymond.hettinger | 2007-03-02 11:20:46 -0800 (Fri, 02 Mar 2007) | 1 line
Fix embarrassing typo and fix constantification of None
........
r54088 | georg.brandl | 2007-03-02 12:30:14 -0800 (Fri, 02 Mar 2007) | 2 lines
Bugs #1668032, #1668036, #1669304: clarify behavior of PyMem_Realloc and _Resize.
........
r54114 | georg.brandl | 2007-03-04 09:18:54 -0800 (Sun, 04 Mar 2007) | 2 lines
Fix a bug in test_dict and test_userdict, found at the PyPy sprint.
........
r54124 | skip.montanaro | 2007-03-04 12:52:28 -0800 (Sun, 04 Mar 2007) | 2 lines
Teach setup.py how to find Berkeley DB on Macs using MacPorts.
........
r54125 | skip.montanaro | 2007-03-04 12:54:12 -0800 (Sun, 04 Mar 2007) | 1 line
note MacPorts/BerkDB change in setup.py
........
r54136 | neal.norwitz | 2007-03-04 23:52:01 -0800 (Sun, 04 Mar 2007) | 1 line
Added Pete for 3101 too
........
r54138 | facundo.batista | 2007-03-05 08:31:54 -0800 (Mon, 05 Mar 2007) | 1 line
Minor corrections to docs, and an explanation comentary
........
r54139 | georg.brandl | 2007-03-05 14:28:08 -0800 (Mon, 05 Mar 2007) | 3 lines
Patch #1674228: when assigning a slice (old-style), check for the
sq_ass_slice instead of the sq_slice slot.
........
r54149 | georg.brandl | 2007-03-06 01:33:01 -0800 (Tue, 06 Mar 2007) | 3 lines
Nit: a struct field is set to GenericAlloc, not GenericAlloc().
........
r54150 | georg.brandl | 2007-03-06 02:02:47 -0800 (Tue, 06 Mar 2007) | 3 lines
Patch #1671450: add a section about subclassing builtin types to the
"extending and embedding" tutorial.
........
r54152 | martin.v.loewis | 2007-03-06 02:41:24 -0800 (Tue, 06 Mar 2007) | 2 lines
Patch #1121142: Implement ZipFile.open.
........
r54154 | georg.brandl | 2007-03-06 03:51:14 -0800 (Tue, 06 Mar 2007) | 2 lines
A test case for the fix in #1674228.
........
r54156 | georg.brandl | 2007-03-06 03:52:24 -0800 (Tue, 06 Mar 2007) | 2 lines
Patch #1672481: fix bug in idlelib.MultiCall.
........
r54159 | georg.brandl | 2007-03-06 04:17:50 -0800 (Tue, 06 Mar 2007) | 1 line
Bug #1674503: close the file opened by execfile() in an error condition.
........
r54160 | georg.brandl | 2007-03-06 05:32:52 -0800 (Tue, 06 Mar 2007) | 3 lines
Fix another reincarnation of bug #1576657 in defaultdict.
........
r54162 | georg.brandl | 2007-03-06 05:35:00 -0800 (Tue, 06 Mar 2007) | 2 lines
A test case for the defaultdict KeyError bug.
........
r54164 | georg.brandl | 2007-03-06 05:37:45 -0800 (Tue, 06 Mar 2007) | 3 lines
Patch #1663234: you can now run doctest on test files and modules
using "python -m doctest [-v] filename ...".
........
r54165 | martin.v.loewis | 2007-03-06 06:43:00 -0800 (Tue, 06 Mar 2007) | 3 lines
Patch #912410: Replace HTML entity references for attribute values
in HTMLParser.
........
r54166 | skip.montanaro | 2007-03-06 07:41:38 -0800 (Tue, 06 Mar 2007) | 1 line
patch 1673619 - identify extension modules which cannot be built
........
r54167 | guido.van.rossum | 2007-03-06 07:50:01 -0800 (Tue, 06 Mar 2007) | 5 lines
Patch #1646728: datetime.fromtimestamp fails with negative
fractional times. With unittest.
Somebody please backport to 2.5.
........
r54169 | georg.brandl | 2007-03-06 09:49:14 -0800 (Tue, 06 Mar 2007) | 2 lines
Fix cmp vs. key argument for list.sort.
........
r54170 | georg.brandl | 2007-03-06 10:21:32 -0800 (Tue, 06 Mar 2007) | 2 lines
Small nit, found by Neal.
........
r54171 | georg.brandl | 2007-03-06 10:29:58 -0800 (Tue, 06 Mar 2007) | 3 lines
Patch #1602128: clarify that richcmp methods can return NotImplemented
and should return True or False otherwise.
........
r54173 | georg.brandl | 2007-03-06 10:41:12 -0800 (Tue, 06 Mar 2007) | 2 lines
Patch #1638879: don't accept strings with embedded NUL bytes in long().
........
r54175 | georg.brandl | 2007-03-06 10:47:31 -0800 (Tue, 06 Mar 2007) | 2 lines
Patch #1673121: update README wrt. OSX default shell.
........
r54177 | georg.brandl | 2007-03-06 10:59:11 -0800 (Tue, 06 Mar 2007) | 3 lines
Patch #1654417: make operator.{get,set,del}slice use the full range
of Py_ssize_t.
........
r54180 | walter.doerwald | 2007-03-06 12:38:57 -0800 (Tue, 06 Mar 2007) | 4 lines
Patch for bug #1633621: if curses.resizeterm() or
curses.resize_term() is called, update _curses.LINES,
_curses.COLS, curses.LINES and curses.COLS.
........
r54182 | walter.doerwald | 2007-03-06 13:15:24 -0800 (Tue, 06 Mar 2007) | 2 lines
Document change to curses.
........
r54188 | georg.brandl | 2007-03-06 16:34:46 -0800 (Tue, 06 Mar 2007) | 5 lines
Variant of patch #697613: don't exit the interpreter on a SystemExit
exception if the -i command line option or PYTHONINSPECT environment
variable is given, but break into the interactive interpreter just like
on other exceptions or normal program exit.
(backport)
........
r54189 | georg.brandl | 2007-03-06 16:40:28 -0800 (Tue, 06 Mar 2007) | 4 lines
Patch #703779: unset __file__ in __main__ after running a file. This
makes the filenames the warning module prints much more sensible when
a PYTHONSTARTUP file is used.
........
r54192 | george.yoshida | 2007-03-06 20:21:18 -0800 (Tue, 06 Mar 2007) | 2 lines
add versionadded info
........
r54195 | georg.brandl | 2007-03-06 23:39:06 -0800 (Tue, 06 Mar 2007) | 2 lines
Patch #812285: allow multiple auth schemes in AbstractBasicAuthHandler.
........
r54197 | georg.brandl | 2007-03-07 00:31:51 -0800 (Wed, 07 Mar 2007) | 3 lines
Patch #1001604: glob.glob() now returns unicode filenames if it was
given a unicode argument and os.listdir() returns unicode filenames.
........
r54199 | georg.brandl | 2007-03-07 01:09:40 -0800 (Wed, 07 Mar 2007) | 3 lines
Patches #1550273, #1550272: fix a few bugs in unittest and add a
comprehensive test suite for the module.
........
r54201 | georg.brandl | 2007-03-07 01:21:06 -0800 (Wed, 07 Mar 2007) | 3 lines
Patch #787789: allow to pass custom TestRunner instances to unittest's
main() function.
........
r54202 | georg.brandl | 2007-03-07 01:34:45 -0800 (Wed, 07 Mar 2007) | 2 lines
Patch #1669331: clarify shutil.copyfileobj() behavior wrt. file position.
........
r54204 | martin.v.loewis | 2007-03-07 03:04:33 -0800 (Wed, 07 Mar 2007) | 2 lines
Bug #1115886: os.path.splitext('.cshrc') gives now ('.cshrc', '').
........
r54206 | georg.brandl | 2007-03-07 03:37:42 -0800 (Wed, 07 Mar 2007) | 2 lines
Patch #1675471: convert test_pty to unittest.
........
r54207 | georg.brandl | 2007-03-07 03:54:49 -0800 (Wed, 07 Mar 2007) | 4 lines
Add some sanity checks to unittest.TestSuite's addTest(s) methods.
Fixes #878275.
........
r54209 | guido.van.rossum | 2007-03-07 07:16:29 -0800 (Wed, 07 Mar 2007) | 3 lines
Windows doesn't support negative timestamps. Skip the tests involving them
if os.name == "nt".
........
r54219 | martin.v.loewis | 2007-03-08 05:42:43 -0800 (Thu, 08 Mar 2007) | 2 lines
Add missing ) in parenthical remark.
........
r54220 | georg.brandl | 2007-03-08 09:49:06 -0800 (Thu, 08 Mar 2007) | 2 lines
Fix #1676656: \em is different from \emph...
........
r54222 | georg.brandl | 2007-03-08 10:37:31 -0800 (Thu, 08 Mar 2007) | 2 lines
Add a NEWS entry for rev. 54207,8.
........
r54225 | raymond.hettinger | 2007-03-08 11:24:27 -0800 (Thu, 08 Mar 2007) | 1 line
SF 1676321: empty() returned wrong result
........
r54227 | collin.winter | 2007-03-08 11:58:14 -0800 (Thu, 08 Mar 2007) | 1 line
Backported r54226 from p3yk: Move test_unittest, test_doctest and test_doctest2 higher up in the testing order.
........
r54230 | raymond.hettinger | 2007-03-08 13:33:47 -0800 (Thu, 08 Mar 2007) | 1 line
SF #1637850: make_table in difflib did not work with unicode
........
r54232 | collin.winter | 2007-03-08 14:16:25 -0800 (Thu, 08 Mar 2007) | 1 line
Patch #1668482: don't use '-' in mkstemp
........
r54233 | brett.cannon | 2007-03-08 15:58:11 -0800 (Thu, 08 Mar 2007) | 10 lines
Introduce test.test_support.TransientResource. It's a context manager to
surround calls to resources that may or may not be available. Specifying the
expected exception and attributes to be raised if the resource is not available
prevents overly broad catching of exceptions.
This is meant to help suppress spurious failures by raising
test.test_support.ResourceDenied if the exception matches. It would probably
be good to go through the various network tests and surround the calls to catch
connection timeouts (as done with test_socket_ssl in this commit).
........
r54234 | collin.winter | 2007-03-08 19:15:56 -0800 (Thu, 08 Mar 2007) | 1 line
Patch #1481079: Support of HTTP_REFERER in CGIHTTPServer.py
........
r54235 | collin.winter | 2007-03-08 19:26:32 -0800 (Thu, 08 Mar 2007) | 1 line
Add NEWS item for patch #1481079 (r54234).
........
r54237 | neal.norwitz | 2007-03-08 21:59:01 -0800 (Thu, 08 Mar 2007) | 1 line
Fix SF #1676971, Complex OverflowError has a typo
........
r54239 | georg.brandl | 2007-03-09 04:58:41 -0800 (Fri, 09 Mar 2007) | 2 lines
Typo.
........
r54240 | martin.v.loewis | 2007-03-09 07:35:55 -0800 (Fri, 09 Mar 2007) | 2 lines
Patch #957003: Implement smtplib.LMTP.
........
r54243 | collin.winter | 2007-03-09 10:09:10 -0800 (Fri, 09 Mar 2007) | 2 lines
Bug #1629566: clarify the docs on the return values of parsedate() and parsedate_tz() in email.utils and rfc822.
........
r54244 | thomas.heller | 2007-03-09 11:21:28 -0800 (Fri, 09 Mar 2007) | 3 lines
Fix bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0)
returned string up to the first NUL character.
........
r54245 | martin.v.loewis | 2007-03-09 11:36:01 -0800 (Fri, 09 Mar 2007) | 2 lines
Add Ziga Seilnacht.
........
r54247 | collin.winter | 2007-03-09 12:33:07 -0800 (Fri, 09 Mar 2007) | 2 lines
Patch #1491866: change the complex() constructor to allow parthensized forms. This means complex(repr(x)) now works instead of raising a ValueError.
........
r54248 | thomas.heller | 2007-03-09 12:39:22 -0800 (Fri, 09 Mar 2007) | 7 lines
Bug #1651235: When a tuple was passed to a ctypes function call,
Python would crash instead of raising an error.
The crash was caused by a section of code that should have been
removed long ago, at that time ctypes had other ways to pass
parameters to function calls.
........
r54250 | collin.winter | 2007-03-09 15:30:39 -0800 (Fri, 09 Mar 2007) | 1 line
Hashing simplification pointed out by Thomas Wouters.
........
r54252 | collin.winter | 2007-03-09 18:23:40 -0800 (Fri, 09 Mar 2007) | 5 lines
* Unlink test files before and after each test; hopefully this will cut down on recent buildbot failures in test_islink.
* Drop safe_remove() in favor of test_support.unlink().
* Fix the indentation of test_samefile so that it runs.
........
r54253 | collin.winter | 2007-03-09 18:51:26 -0800 (Fri, 09 Mar 2007) | 3 lines
Bug #1531963: Make SocketServer.TCPServer's server_address always be equal to calling getsockname() on the server's socket.
Will backport.
........
r54254 | neal.norwitz | 2007-03-09 19:19:18 -0800 (Fri, 09 Mar 2007) | 4 lines
Simplify a little by handling the TCP case first.
Update to use predominant style of spaces around = in args list
and print to stderr if debugging.
........
r54256 | collin.winter | 2007-03-09 19:35:34 -0800 (Fri, 09 Mar 2007) | 1 line
Add proper attribution for a bug fix.
........
r54257 | georg.brandl | 2007-03-09 23:38:14 -0800 (Fri, 09 Mar 2007) | 2 lines
Typos.
........
r54260 | collin.winter | 2007-03-10 06:33:32 -0800 (Sat, 10 Mar 2007) | 1 line
Convert an assert to a raise so it works even in the presence of -O.
........
r54262 | collin.winter | 2007-03-10 06:41:48 -0800 (Sat, 10 Mar 2007) | 2 lines
Patch #1599845: Add an option to disable the implicit calls to server_bind() and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer and DocXMLRPCServer.
........
r54268 | georg.brandl | 2007-03-11 00:28:46 -0800 (Sun, 11 Mar 2007) | 2 lines
Add missing "return" statements in exception handler.
........
r54270 | ziga.seilnacht | 2007-03-11 08:54:54 -0700 (Sun, 11 Mar 2007) | 3 lines
Patch #1675981: remove unreachable code from type.__new__() method.
__dict__ and __weakref__ are removed from the slots tuple earlier
in the code, in the loop that mangles slot names. Will backport.
........
r54271 | collin.winter | 2007-03-11 09:00:20 -0700 (Sun, 11 Mar 2007) | 3 lines
Patch #1192590: Fix pdb's "ignore" and "condition" commands so they trap the IndexError caused by passing in an invalid breakpoint number.
Will backport.
........
r54274 | vinay.sajip | 2007-03-11 11:32:07 -0700 (Sun, 11 Mar 2007) | 1 line
Fix resource leak reported in SF #1516995.
........
r54278 | collin.winter | 2007-03-11 18:55:54 -0700 (Sun, 11 Mar 2007) | 4 lines
Patch #1678662: ftp.python.org does not exist. So the testcode in urllib.py must use a more
stable FTP.
Will backport.
........
r54280 | barry.warsaw | 2007-03-11 20:20:01 -0700 (Sun, 11 Mar 2007) | 8 lines
Tokio Kikuchi's fix for SF bug #1629369; folding whitespace allowed in the
display name of an email address, e.g.
Foo
\tBar <foo@example.com>
Test case added by Barry.
........
r54282 | skip.montanaro | 2007-03-11 20:30:50 -0700 (Sun, 11 Mar 2007) | 4 lines
Sane humans would call these invalid tests, but Andrew McNamara pointed out
that given the inputs in these tests Excel does indeed produce the output
these tests expect. Document that for future confused folks.
........
r54283 | martin.v.loewis | 2007-03-12 03:50:39 -0700 (Mon, 12 Mar 2007) | 2 lines
Bug #1675511: Use -Kpic instead of -xcode=pic32 on Solaris/x86.
........
r54285 | martin.v.loewis | 2007-03-12 04:01:10 -0700 (Mon, 12 Mar 2007) | 2 lines
Patch #1677862: Require a space or tab after import in .pth files.
........
r54287 | georg.brandl | 2007-03-12 06:17:36 -0700 (Mon, 12 Mar 2007) | 8 lines
Backport from Py3k branch:
Patch #1591665: implement the __dir__() special function lookup in PyObject_Dir.
Had to change a few bits of the patch because classobjs and __methods__ are still
in Py2.6.
........
r54288 | georg.brandl | 2007-03-12 07:30:05 -0700 (Mon, 12 Mar 2007) | 3 lines
Bug #1678647: write a newline after printing an exception in any
case, even when converting the value to a string failed.
........
r54290 | collin.winter | 2007-03-12 08:57:19 -0700 (Mon, 12 Mar 2007) | 1 line
Patch #1678088: convert test_operations to use unittest, fold the result into test_dict.
........
r54291 | collin.winter | 2007-03-12 09:11:39 -0700 (Mon, 12 Mar 2007) | 3 lines
Bug #742342: make Python stop segfaulting on infinitely-recursive reload()s. Fixed by patch #922167.
Will backport.
........
r54292 | georg.brandl | 2007-03-12 09:15:09 -0700 (Mon, 12 Mar 2007) | 2 lines
Typo fix.
........
r54295 | collin.winter | 2007-03-12 10:24:07 -0700 (Mon, 12 Mar 2007) | 1 line
Patch #1670993: Refactor test_threadedtempfile.py to use unittest.
........
r54296 | tim.peters | 2007-03-12 11:07:52 -0700 (Mon, 12 Mar 2007) | 2 lines
Whitespace normalization.
........
r54297 | tim.peters | 2007-03-12 11:09:22 -0700 (Mon, 12 Mar 2007) | 2 lines
Set missing svn:eol-style property on text files.
........
r54315 | brett.cannon | 2007-03-12 19:34:09 -0700 (Mon, 12 Mar 2007) | 8 lines
Add test.test_support.transient_internet . Returns a context manager that
nests test.test_support.TransientResource context managers that capture
exceptions raised when the Internet connection is flaky.
Initially using in test_socket_ssl but should probably be expanded to cover any
test that should not raise the captured exceptions if the Internet connection
works.
........
r54316 | brett.cannon | 2007-03-12 20:05:40 -0700 (Mon, 12 Mar 2007) | 2 lines
Fix a typo where the variable name was not updated.
........
r54318 | neal.norwitz | 2007-03-12 21:59:58 -0700 (Mon, 12 Mar 2007) | 1 line
Add Jerry Seutter for a bunch of his recent patches refactoring tests
........
r54319 | neal.norwitz | 2007-03-12 22:07:14 -0700 (Mon, 12 Mar 2007) | 7 lines
Add some other acks for recent checkins:
Brian Leair - 922167
Tomer Filiba - 1591665
Jeremy Jones - 1192590
........
r54321 | neal.norwitz | 2007-03-12 22:31:38 -0700 (Mon, 12 Mar 2007) | 9 lines
Fix some style nits:
* lines too long
* wrong indentation
* space after a function name
* wrong function name in error string
* simplifying some logic
Also add an error check to PyDict_SetItemString.
........
r54322 | georg.brandl | 2007-03-13 00:23:16 -0700 (Tue, 13 Mar 2007) | 2 lines
Typo and grammar fixes.
........
r54323 | georg.brandl | 2007-03-13 00:50:57 -0700 (Tue, 13 Mar 2007) | 2 lines
Patch #1679379: add documentation for fnmatch.translate().
........
r54325 | georg.brandl | 2007-03-13 00:57:51 -0700 (Tue, 13 Mar 2007) | 2 lines
Patch #1642844: comments to clarify the complexobject constructor.
........
r54326 | georg.brandl | 2007-03-13 01:14:27 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1668100: urllib2 now correctly raises URLError instead of
OSError if accessing a local file via the file:// protocol fails.
........
r54327 | georg.brandl | 2007-03-13 02:32:11 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #1635454: the csv.DictWriter class now includes the offending
field names in its exception message if you try to write a record with
a dictionary containing fields not in the CSV field names list.
........
r54328 | georg.brandl | 2007-03-13 02:41:31 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1555098: use str.join() instead of repeated string
concatenation in robotparser.
........
r54329 | georg.brandl | 2007-03-13 03:06:48 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1542681: add entries for "with", "as" and "CONTEXTMANAGERS" to
pydoc's help keywords.
........
r54331 | georg.brandl | 2007-03-13 03:19:22 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1569798: fix a bug in distutils when building Python from a
directory within sys.exec_prefix.
........
r54333 | martin.v.loewis | 2007-03-13 03:24:00 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #1449244: Support Unicode strings in
email.message.Message.{set_charset,get_content_charset}.
Will backport.
........
r54335 | lars.gustaebel | 2007-03-13 03:47:19 -0700 (Tue, 13 Mar 2007) | 34 lines
This is the implementation of POSIX.1-2001 (pax) format read/write
support.
The TarInfo class now contains all necessary logic to process and
create tar header data which has been moved there from the TarFile
class. The fromtarfile() method was added. The new path and linkpath
properties are aliases for the name and linkname attributes in
correspondence to the pax naming scheme.
The TarFile constructor and classmethods now accept a number of
keyword arguments which could only be set as attributes before (e.g.
dereference, ignore_zeros). The encoding and pax_headers arguments
were added for pax support. There is a new tarinfo keyword argument
that allows using subclassed TarInfo objects in TarFile.
The boolean TarFile.posix attribute is deprecated, because now three
tar formats are supported. Instead, the desired format for writing is
specified using the constants USTAR_FORMAT, GNU_FORMAT and PAX_FORMAT
as the format keyword argument. This change affects TarInfo.tobuf()
as well.
The test suite has been heavily reorganized and partially rewritten.
A new testtar.tar was added that contains sample data in many formats
from 4 different tar programs.
Some bugs and quirks that also have been fixed:
Directory names do no longer have a trailing slash in TarInfo.name or
TarFile.getnames().
Adding the same file twice does not create a hardlink file member.
The TarFile constructor does no longer need a name argument.
The TarFile._mode attribute was renamed to mode and contains either
'r', 'w' or 'a'.
........
r54336 | georg.brandl | 2007-03-13 05:34:25 -0700 (Tue, 13 Mar 2007) | 3 lines
Bug #1622896: fix a rare corner case where the bz2 module raised an
error in spite of a succesful compression.
........
r54338 | lars.gustaebel | 2007-03-13 08:47:07 -0700 (Tue, 13 Mar 2007) | 3 lines
Quick fix for tests that fail on systems with an encoding other
than 'iso8859-1'.
........
r54339 | georg.brandl | 2007-03-13 10:43:32 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #1603688: ConfigParser.SafeConfigParser now checks values that
are set for invalid interpolation sequences that would lead to errors
on reading back those values.
........
r54341 | georg.brandl | 2007-03-13 11:15:41 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1581073: add a flag to textwrap that prevents the dropping of
whitespace while wrapping.
........
r54343 | georg.brandl | 2007-03-13 11:24:40 -0700 (Tue, 13 Mar 2007) | 2 lines
Patch #1605192: list allowed states in error messages for imaplib.
........
r54344 | georg.brandl | 2007-03-13 11:31:49 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #1537850: tempfile.NamedTemporaryFile now has a "delete" parameter
which can be set to False to prevent the default delete-on-close
behavior.
........
r54345 | collin.winter | 2007-03-13 11:53:04 -0700 (Tue, 13 Mar 2007) | 9 lines
Add acks for recent patch checkins:
Arvin Schnell - 1668482
S?\195?\169bastien Martini - 1481079
Heiko Wundram - 1491866
Damon Kohler - 1545011
Peter Parente - 1599845
Bjorn Lindqvist - 1678662
........
r54346 | georg.brandl | 2007-03-13 12:00:36 -0700 (Tue, 13 Mar 2007) | 2 lines
Acks for recent patches.
........
r54347 | georg.brandl | 2007-03-13 12:18:18 -0700 (Tue, 13 Mar 2007) | 3 lines
Fix a tab.
........
r54348 | georg.brandl | 2007-03-13 12:32:21 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #1533909: the timeit module now accepts callables in addition to
strings for the code to time and the setup code. Also added two
convenience functions for instantiating a Timer and calling its methods.
........
r54352 | georg.brandl | 2007-03-13 13:02:57 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1530482: add pydoc.render_doc() which returns the documentation
for a thing instead of paging it to stdout, which pydoc.doc() does.
........
r54357 | thomas.heller | 2007-03-13 13:42:52 -0700 (Tue, 13 Mar 2007) | 1 line
Patch #1649190: Adding support for _Bool to ctypes as c_bool, by David Remahl.
........
r54358 | georg.brandl | 2007-03-13 13:46:32 -0700 (Tue, 13 Mar 2007) | 2 lines
Patch #1444529: the builtin compile() now accepts keyword arguments.
(backport)
........
r54359 | thomas.heller | 2007-03-13 14:01:39 -0700 (Tue, 13 Mar 2007) | 1 line
Add versionadded marker for ctypes.c_bool.
........
r54360 | georg.brandl | 2007-03-13 14:08:15 -0700 (Tue, 13 Mar 2007) | 3 lines
Patch #1393667: pdb now has a "run" command which restarts the debugged
Python program, optionally with different arguments.
........
r54361 | georg.brandl | 2007-03-13 14:32:01 -0700 (Tue, 13 Mar 2007) | 3 lines
Deprecate commands.getstatus().
........
r54362 | georg.brandl | 2007-03-13 14:32:56 -0700 (Tue, 13 Mar 2007) | 2 lines
NEWS entry for getstatus() deprecation.
........
r54363 | georg.brandl | 2007-03-13 14:58:44 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #1429539: pdb now correctly initializes the __main__ module for
the debugged script, which means that imports from __main__ work
correctly now.
........
r54364 | georg.brandl | 2007-03-13 15:07:36 -0700 (Tue, 13 Mar 2007) | 4 lines
Patch #957650: "%var%" environment variable references are now properly
expanded in ntpath.expandvars(), also "~user" home directory references
are recognized and handled on Windows.
........
r54365 | georg.brandl | 2007-03-13 15:16:30 -0700 (Tue, 13 Mar 2007) | 2 lines
Patch #1194449: correctly detect unbound methods in pydoc.
........
r54367 | georg.brandl | 2007-03-13 15:49:43 -0700 (Tue, 13 Mar 2007) | 5 lines
Patch #1185447: binascii.b2a_qp() now correctly quotes binary characters
with ASCII value less than 32. Also, it correctly quotes dots only if
they occur on a single line, as opposed to the previous behavior of
quoting dots if they are the second character of any line.
........
r54368 | collin.winter | 2007-03-13 16:02:15 -0700 (Tue, 13 Mar 2007) | 1 line
Inline PyImport_GetModulesReloading().
........
r54371 | barry.warsaw | 2007-03-13 21:59:50 -0700 (Tue, 13 Mar 2007) | 6 lines
SF bug #1582282; decode_header() incorrectly splits not-conformant RFC
2047-like headers where there is no whitespace between encoded words. This
fix changes the matching regexp to include a trailing lookahead assertion that
the closing ?= must be followed by whitespace, newline, or end-of-string.
This also changes the regexp to add the MULTILINE flag.
........
r54372 | gregory.p.smith | 2007-03-14 00:17:40 -0700 (Wed, 14 Mar 2007) | 2 lines
correct order and names of the less often used keyword parameters.
........
r54373 | gregory.p.smith | 2007-03-14 00:19:50 -0700 (Wed, 14 Mar 2007) | 5 lines
Its time to stop listing (Unix, Windows) when we really mean "everything but Mac OS 9"
now that nobody is likely to use Python on Mac OS 9 and most of the (Mac) platform
items are all OS X special API specific since OS X is unixy enough for these modules
to be available out of the box.
........
r54376 | georg.brandl | 2007-03-14 01:27:52 -0700 (Wed, 14 Mar 2007) | 4 lines
Bug #767111: fix long-standing bug in urllib which caused an
AttributeError instead of an IOError when the server's response didn't
contain a valid HTTP status line.
........
r54378 | ziga.seilnacht | 2007-03-14 05:24:09 -0700 (Wed, 14 Mar 2007) | 4 lines
Patch #1680015: Don't modify __slots__ tuple if it contains an unicode
name. Remove a reference leak that happened if the name could not be
converted to string. Will backport.
........
r54386 | martin.v.loewis | 2007-03-14 13:02:31 -0700 (Wed, 14 Mar 2007) | 3 lines
Patch #1559413: Fix test_cmd_line if sys.executable contains a space.
Will backport.
........
r54389 | brett.cannon | 2007-03-14 14:40:13 -0700 (Wed, 14 Mar 2007) | 3 lines
Note how test_socket_ssl has various exceptions that deal with a flaky Net
connection are silenced.
........
r54390 | brett.cannon | 2007-03-14 14:44:15 -0700 (Wed, 14 Mar 2007) | 2 lines
Raise ResourceDenied in test_urllib2net when the Net connection goes bad.
........
r54391 | neal.norwitz | 2007-03-14 21:41:20 -0700 (Wed, 14 Mar 2007) | 1 line
Wrap a long line and fix a typo (is -> if)
........
r54392 | georg.brandl | 2007-03-15 00:38:14 -0700 (Thu, 15 Mar 2007) | 3 lines
Patch #1680978: consistently use "alive" instead of "active" in the
thread lib doc.
........
r54394 | georg.brandl | 2007-03-15 00:41:30 -0700 (Thu, 15 Mar 2007) | 3 lines
Patch #1681153: the wave module now closes a file object it opened if
initialization failed.
........
r54397 | ziga.seilnacht | 2007-03-15 04:44:55 -0700 (Thu, 15 Mar 2007) | 3 lines
Patch #1462488: prevent a segfault in object_reduce_ex() by splitting
the implementation for __reduce__ and __reduce_ex__ into two separate
functions. Fixes bug #931877. Will backport.
........
r54404 | collin.winter | 2007-03-15 21:11:30 -0700 (Thu, 15 Mar 2007) | 3 lines
Patch #1642547: Fix an error/crash when encountering syntax errors in complex if statements.
Will backport.
........
r54406 | georg.brandl | 2007-03-16 00:55:09 -0700 (Fri, 16 Mar 2007) | 5 lines
Bug #1681228: the webbrowser module now correctly uses the default
GNOME or KDE browser, depending on whether there is a session of one
of those present. Also, it tries the Windows default browser before
trying Mozilla variants.
(backport)
........
r54407 | georg.brandl | 2007-03-16 01:22:40 -0700 (Fri, 16 Mar 2007) | 4 lines
Patch #1273829: os.walk() now has a "followlinks" parameter. If set to
True (which is not the default), it visits symlinks pointing to
directories.
........
r54408 | georg.brandl | 2007-03-16 01:24:21 -0700 (Fri, 16 Mar 2007) | 2 lines
Add \versionadded tag.
........
r54409 | georg.brandl | 2007-03-16 01:33:47 -0700 (Fri, 16 Mar 2007) | 2 lines
RFE #1670167: fix in isinstance() docs.
........
r54412 | ziga.seilnacht | 2007-03-16 04:59:38 -0700 (Fri, 16 Mar 2007) | 3 lines
Patch #1623563: allow __class__ assignment for classes with __slots__.
The old and the new class are still required to have the same slot
names, but the order in which they are specified is not relevant.
........
r54413 | ziga.seilnacht | 2007-03-16 05:11:11 -0700 (Fri, 16 Mar 2007) | 2 lines
Whitespace cleanup. Also remove the empty lines
from the previous check in.
........
r54414 | jeremy.hylton | 2007-03-16 07:49:11 -0700 (Fri, 16 Mar 2007) | 2 lines
Remove warning: funcion declaration isn't a prototype
........
r54415 | jeremy.hylton | 2007-03-16 08:59:47 -0700 (Fri, 16 Mar 2007) | 11 lines
Clean up formatting of this file.
The file should now follow PEP 7, except that it uses 4 space indents
(in the style of Py3k). This particular code would be really hard to
read with the regular tab idents.
Other changes:
- reflow long lines
- change multi-line conditionals to have test at end of line
........
r54417 | collin.winter | 2007-03-16 14:13:35 -0700 (Fri, 16 Mar 2007) | 1 line
Patch #1676994: Refactor test_popen2 to use unittest.
........
r54418 | collin.winter | 2007-03-16 14:15:35 -0700 (Fri, 16 Mar 2007) | 1 line
Remove test/output/test_popen2 (missed in r54417).
........
r54419 | collin.winter | 2007-03-16 15:16:08 -0700 (Fri, 16 Mar 2007) | 1 line
Patch 1339796: add a relpath() function to os.path.
........
r54421 | georg.brandl | 2007-03-17 09:08:45 -0700 (Sat, 17 Mar 2007) | 5 lines
Patch #1675423: PyComplex_AsCComplex() now tries to convert an object
to complex using its __complex__() method before falling back to the
__float__() method. Therefore, the functions in the cmath module now
can operate on objects that define a __complex__() method.
(backport)
........
r54423 | gregory.p.smith | 2007-03-17 15:33:35 -0700 (Sat, 17 Mar 2007) | 2 lines
move note to the correct section
........
r54426 | georg.brandl | 2007-03-18 01:25:00 -0700 (Sun, 18 Mar 2007) | 2 lines
Patch #1682878: the new socket methods are recv_into and recvfrom_into, not *_buf.
........
r54432 | georg.brandl | 2007-03-18 11:28:25 -0700 (Sun, 18 Mar 2007) | 2 lines
Patch #1678339: test case for bug in difflib.
........
r54439 | collin.winter | 2007-03-19 11:52:08 -0700 (Mon, 19 Mar 2007) | 1 line
Patch #1630118: add a SpooledTemporaryFile class to tempfile.
........
r54441 | georg.brandl | 2007-03-19 12:02:48 -0700 (Mon, 19 Mar 2007) | 2 lines
Patch #1683328: fixes and enhancements for "unparse" demo.
........
r54456 | neal.norwitz | 2007-03-19 22:07:28 -0700 (Mon, 19 Mar 2007) | 1 line
Add some doc that was left out from some change to platform.py
........
r54457 | neal.norwitz | 2007-03-19 22:08:23 -0700 (Mon, 19 Mar 2007) | 1 line
Add a comment about 3k migration
........
r54458 | neal.norwitz | 2007-03-19 22:21:21 -0700 (Mon, 19 Mar 2007) | 1 line
Get rid of deprecation warning when testing commands.getstatus()
........
r54459 | neal.norwitz | 2007-03-19 22:23:09 -0700 (Mon, 19 Mar 2007) | 4 lines
Try backing out 54407 to see if it corrects the problems on the Windows
buildbots. This rev was backported, so we will need to keep both branches
in sync, pending the outcome of the test after this checkin.
........
r54460 | neal.norwitz | 2007-03-19 23:13:25 -0700 (Mon, 19 Mar 2007) | 1 line
Try to make this test more resistant to dropping from previous runs (ie, files that may exist but cause the test to fail). Should be backported (assuming it works :-)
........
r54461 | neal.norwitz | 2007-03-19 23:16:26 -0700 (Mon, 19 Mar 2007) | 1 line
Try to make this test more resistant to dropping from previous runs (ie, files that may exist but cause the test to fail). Should be backported (assuming it works :-)
........
r54462 | neal.norwitz | 2007-03-19 23:53:17 -0700 (Mon, 19 Mar 2007) | 5 lines
Try to be a little more resilient to errors. This might help the test
pass, but my guess is that it won't. I'm guessing that some other
test is leaving this file open which means it can't be removed
under Windows AFAIK.
........
r54463 | neal.norwitz | 2007-03-20 01:14:57 -0700 (Tue, 20 Mar 2007) | 8 lines
Try to get test_urllib to pass on Windows by closing the file.
I'm guessing that's the problem. h.getfile() must be called *after*
h.getreply() and the fp can be None.
I'm not entirely convinced this is the best fix (or even correct).
The buildbots will tell us if things improve or not. I don't
know if this needs to be backported (assuming it actually works).
........
r54465 | raymond.hettinger | 2007-03-20 14:27:24 -0700 (Tue, 20 Mar 2007) | 1 line
Extend work on rev 52962 and 53829 eliminating redundant PyObject_Hash() calls and fixing set/dict interoperability.
........
r54468 | georg.brandl | 2007-03-20 16:05:14 -0700 (Tue, 20 Mar 2007) | 2 lines
Fix for glob.py if filesystem encoding is None.
........
r54479 | neal.norwitz | 2007-03-20 23:39:48 -0700 (Tue, 20 Mar 2007) | 1 line
Remove unused file spotted by Paul Hankin
........
r54480 | georg.brandl | 2007-03-21 02:00:39 -0700 (Wed, 21 Mar 2007) | 3 lines
Patch #1682205: a TypeError while unpacking an iterable is no longer
masked by a generic one with the message "unpack non-sequence".
........
r54482 | georg.brandl | 2007-03-21 02:10:29 -0700 (Wed, 21 Mar 2007) | 2 lines
New test for rev. 54407 which only uses directories under TESTFN.
........
r54483 | georg.brandl | 2007-03-21 02:16:53 -0700 (Wed, 21 Mar 2007) | 2 lines
Patch #1684834: document some utility C API functions.
........
r54485 | georg.brandl | 2007-03-21 04:51:25 -0700 (Wed, 21 Mar 2007) | 2 lines
Fix #1684254: split BROWSER contents with shlex to avoid displaying 'URL'.
........
r54487 | andrew.kuchling | 2007-03-21 07:32:43 -0700 (Wed, 21 Mar 2007) | 1 line
Add comments on maintenance of this file
........
r54489 | andrew.kuchling | 2007-03-21 09:57:32 -0700 (Wed, 21 Mar 2007) | 1 line
Fix sentence, and fix typo in example
........
r54490 | andrew.kuchling | 2007-03-21 09:59:20 -0700 (Wed, 21 Mar 2007) | 1 line
Put code examples at left margin instead of indenting them
........
r54491 | facundo.batista | 2007-03-21 12:41:24 -0700 (Wed, 21 Mar 2007) | 1 line
Minor clarification, saying that blocking means no timeout (from bug #882297)
........
r54492 | ziga.seilnacht | 2007-03-21 13:07:56 -0700 (Wed, 21 Mar 2007) | 2 lines
Bug #1675967: re patterns pickled with older Python versions can
now be unpickled. Will backport.
........
r54495 | raymond.hettinger | 2007-03-21 13:33:57 -0700 (Wed, 21 Mar 2007) | 1 line
Add test and fix for fromkeys() optional argument.
........
r54524 | georg.brandl | 2007-03-22 01:05:45 -0700 (Thu, 22 Mar 2007) | 2 lines
Bug #1685704: use -m switch in timeit docs.
........
r54533 | thomas.heller | 2007-03-22 12:44:31 -0700 (Thu, 22 Mar 2007) | 5 lines
Back out "Patch #1643874: memory leak in ctypes fixed."
The code in this patch leaves no way to give up the ownership of a
BSTR instance.
........
r54538 | thomas.heller | 2007-03-22 13:34:37 -0700 (Thu, 22 Mar 2007) | 2 lines
Explain the purpose of the b_needsfree flag (forward ported from release25-maint).
........
r54539 | guido.van.rossum | 2007-03-22 21:58:42 -0700 (Thu, 22 Mar 2007) | 12 lines
- Bug #1683368: The object.__init__() and object.__new__() methods are
now stricter in rejecting excess arguments. The only time when
either allows excess arguments is when it is not overridden and the
other one is. For backwards compatibility, when both are
overridden, it is a deprecation warning (for now; maybe a Py3k
warning later).
When merging this into 3.0, the warnings should become errors.
Note: without the change to string.py, lots of spurious warnings happen.
What's going on there?
........
r54540 | neal.norwitz | 2007-03-22 22:17:23 -0700 (Thu, 22 Mar 2007) | 1 line
Add Mark Dickinson for SF # 1675423.
........
r54541 | martin.v.loewis | 2007-03-23 03:35:49 -0700 (Fri, 23 Mar 2007) | 3 lines
Patch #1686451: Fix return type for PySequence_{Count,Index,Fast_GET_SIZE}.
Will backport.
........
r54543 | martin.v.loewis | 2007-03-23 06:27:15 -0700 (Fri, 23 Mar 2007) | 3 lines
Bug #978833: Revert r50844, as it broke _socketobject.dup.
Will backport.
........
r54545 | guido.van.rossum | 2007-03-23 11:53:03 -0700 (Fri, 23 Mar 2007) | 8 lines
Add a type.__init__() method that enforces the same signature as
type.__new__(), and then calls object.__init__(cls), just to be anal.
This allows us to restore the code in string.py's _TemplateMetaclass
that called super(...).__init__(name, bases, dct), which I commented
out yesterday since it broke due to the stricter argument checking
added to object.__init__().
........
r54546 | facundo.batista | 2007-03-23 11:54:07 -0700 (Fri, 23 Mar 2007) | 4 lines
Added a 'create_connect()' function to socket.py, which creates a
connection with an optional timeout, and modified httplib.py to
use this function in HTTPConnection. Applies patch 1676823.
........
r54547 | guido.van.rossum | 2007-03-23 12:39:01 -0700 (Fri, 23 Mar 2007) | 2 lines
Add note about type.__init__().
........
r54553 | thomas.heller | 2007-03-23 12:55:27 -0700 (Fri, 23 Mar 2007) | 5 lines
Prevent creation (followed by a segfault) of array types when the size
overflows the valid Py_ssize_t range. Check return values of
PyMem_Malloc.
Will backport to release25-maint.
........
r54555 | facundo.batista | 2007-03-23 13:23:08 -0700 (Fri, 23 Mar 2007) | 6 lines
Surrounded with try/finally to socket's default timeout setting
changes in the tests, so failing one test won't produce strange
results in others. Also relaxed the timeout settings in the test
(where actually the value didn't mean anything).
........
r54556 | collin.winter | 2007-03-23 15:24:39 -0700 (Fri, 23 Mar 2007) | 1 line
Make test_relpath() pass on Windows.
........
r54559 | ziga.seilnacht | 2007-03-24 07:24:26 -0700 (Sat, 24 Mar 2007) | 6 lines
Patch #1489771: update syntax rules in Python Reference Manual.
Python 2.5 added support for explicit relative import statements and
yield expressions, which were missing in the manual.
Also fix grammar productions that used the names from the Grammar file,
markup that broke the generated grammar.txt, and wrap some lines that
broke the pdf output. Will backport.
........
r54565 | georg.brandl | 2007-03-24 15:20:34 -0700 (Sat, 24 Mar 2007) | 2 lines
Remove typo accent.
........
r54566 | georg.brandl | 2007-03-24 15:27:56 -0700 (Sat, 24 Mar 2007) | 2 lines
Revert accidental change.
........
r54567 | brett.cannon | 2007-03-24 18:32:36 -0700 (Sat, 24 Mar 2007) | 3 lines
Change the docs to no longer claim that unittest is preferred over doctest for
regression tests.
........
r54568 | facundo.batista | 2007-03-24 18:53:21 -0700 (Sat, 24 Mar 2007) | 4 lines
Redone the tests, using the infrastructure already present
for threading and socket serving.
........
r54570 | facundo.batista | 2007-03-24 20:20:05 -0700 (Sat, 24 Mar 2007) | 3 lines
Closing the HTTP connection after each test, and listening more.
........
r54572 | georg.brandl | 2007-03-25 11:44:35 -0700 (Sun, 25 Mar 2007) | 2 lines
Markup fix.
........
r54573 | georg.brandl | 2007-03-25 12:04:55 -0700 (Sun, 25 Mar 2007) | 2 lines
Markup fix.
........
r54580 | facundo.batista | 2007-03-26 13:18:31 -0700 (Mon, 26 Mar 2007) | 5 lines
Added an optional timeout to FTP class. Also I started a test_ftplib.py
file to test the ftp lib (right now I included a basic test, the timeout
one, and nothing else).
........
r54581 | georg.brandl | 2007-03-26 13:28:28 -0700 (Mon, 26 Mar 2007) | 2 lines
Some nits.
........
r54582 | facundo.batista | 2007-03-26 13:56:09 -0700 (Mon, 26 Mar 2007) | 4 lines
Forgot to add the file before the previous commit, here go
the ftplib tests.
........
r54585 | facundo.batista | 2007-03-27 11:23:21 -0700 (Tue, 27 Mar 2007) | 5 lines
Added an optional timeout to poplib.POP3. Also created a
test_poplib.py file with a basic test and the timeout
ones. Docs are also updated.
........
r54586 | facundo.batista | 2007-03-27 11:50:29 -0700 (Tue, 27 Mar 2007) | 3 lines
The basic test cases of poplib.py.
........
r54594 | facundo.batista | 2007-03-27 20:45:20 -0700 (Tue, 27 Mar 2007) | 4 lines
Bug 1688393. Adds a control of negative values in
socket.recvfrom, which caused an ugly crash.
........
r54599 | facundo.batista | 2007-03-28 11:25:54 -0700 (Wed, 28 Mar 2007) | 5 lines
Added timeout to smtplib (to SMTP and SMTP_SSL). Also created
the test_smtplib.py file, with a basic test and the timeout
ones. Docs are updated too.
........
r54603 | collin.winter | 2007-03-28 16:34:06 -0700 (Wed, 28 Mar 2007) | 3 lines
Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file.
Thanks to Jerry Seutter for all three patches.
........
r54604 | collin.winter | 2007-03-28 19:28:16 -0700 (Wed, 28 Mar 2007) | 1 line
Make test_zipfile clean up its temporary files properly.
........
r54605 | georg.brandl | 2007-03-29 00:41:32 -0700 (Thu, 29 Mar 2007) | 2 lines
These are actually methods.
........
r54606 | georg.brandl | 2007-03-29 05:42:07 -0700 (Thu, 29 Mar 2007) | 4 lines
In Windows' time.clock(), when QueryPerformanceFrequency() fails,
the C lib's clock() is used, but it must be divided by CLOCKS_PER_SEC
as for the POSIX implementation (thanks to #pypy).
........
r54608 | facundo.batista | 2007-03-29 11:22:35 -0700 (Thu, 29 Mar 2007) | 5 lines
Added timout parameter to telnetlib.Telnet. Also created
test_telnetlib.py with a basic test and timeout ones.
Docs are also updated.
........
r54613 | facundo.batista | 2007-03-30 06:00:35 -0700 (Fri, 30 Mar 2007) | 4 lines
Added the posibility to pass the timeout to FTP.connect, not only when
instantiating the class. Docs and tests are updated.
........
r54614 | collin.winter | 2007-03-30 07:01:25 -0700 (Fri, 30 Mar 2007) | 1 line
Bug #1688274: add documentation for C-level class objects.
........
r54615 | marc-andre.lemburg | 2007-03-30 08:01:42 -0700 (Fri, 30 Mar 2007) | 4 lines
Bump the patch level version of distutils since there were a few bug fixes since
the 2.5.0 release.
........
r54617 | georg.brandl | 2007-03-30 08:49:05 -0700 (Fri, 30 Mar 2007) | 2 lines
Markup fix.
........
r54618 | georg.brandl | 2007-03-30 10:39:39 -0700 (Fri, 30 Mar 2007) | 2 lines
Label name fix.
........
r54619 | georg.brandl | 2007-03-30 10:47:21 -0700 (Fri, 30 Mar 2007) | 2 lines
Duplicate label fix.
........
r54620 | georg.brandl | 2007-03-30 10:48:39 -0700 (Fri, 30 Mar 2007) | 2 lines
Markup fix.
........
r54623 | andrew.kuchling | 2007-03-30 11:00:15 -0700 (Fri, 30 Mar 2007) | 1 line
Add item. (Oops, accidentally checked this in on my branch)
........
r54624 | georg.brandl | 2007-03-30 12:01:38 -0700 (Fri, 30 Mar 2007) | 2 lines
Duplicate label fix.
........
r54625 | georg.brandl | 2007-03-30 12:14:02 -0700 (Fri, 30 Mar 2007) | 2 lines
Markup fix.
........
r54629 | georg.brandl | 2007-03-31 03:17:31 -0700 (Sat, 31 Mar 2007) | 2 lines
repair string literal.
........
r54630 | georg.brandl | 2007-03-31 04:54:58 -0700 (Sat, 31 Mar 2007) | 2 lines
Markup fix.
........
r54631 | georg.brandl | 2007-03-31 04:58:36 -0700 (Sat, 31 Mar 2007) | 2 lines
Duplicate label fix.
........
r54632 | georg.brandl | 2007-03-31 04:59:54 -0700 (Sat, 31 Mar 2007) | 2 lines
Typo fix.
........
r54633 | neal.norwitz | 2007-03-31 11:54:18 -0700 (Sat, 31 Mar 2007) | 1 line
Fix method names. Will backport.
........
r54634 | georg.brandl | 2007-03-31 11:56:11 -0700 (Sat, 31 Mar 2007) | 4 lines
Bug #1655392: don't add -L/usr/lib/pythonX.Y/config to the LDFLAGS
returned by python-config if Python was built with --enable-shared
because that prevented the shared library from being used.
........
r54637 | collin.winter | 2007-03-31 12:31:34 -0700 (Sat, 31 Mar 2007) | 1 line
Shut up an occaisonal buildbot error due to test files being left around.
........
r54644 | neal.norwitz | 2007-04-01 11:24:22 -0700 (Sun, 01 Apr 2007) | 11 lines
SF #1685563, MSVCCompiler creates redundant and long PATH strings
If MSVCCompiler.initialize() was called multiple times, the path
would get duplicated. On Windows, this is a problem because the
path is limited to 4k. There's no benefit in adding a path multiple
times, so prevent that from occuring. We also normalize the path
before checking for duplicates so things like /a and /a/ won't both
be stored.
Will backport.
........
r54646 | brett.cannon | 2007-04-01 11:47:27 -0700 (Sun, 01 Apr 2007) | 8 lines
time.strptime's caching of its locale object was being recreated when the
locale changed but not used during the function call it was recreated during.
The test in this checkin is untested (OS X does not have the proper locale
support for me to test), although the fix for the bug this deals with
was tested by the OP (#1290505). Once the buildbots verify the test at least
doesn't fail it becomes a backport candidate.
........
r54647 | brett.cannon | 2007-04-01 12:46:19 -0700 (Sun, 01 Apr 2007) | 3 lines
Fix the test for recreating the locale cache object by not worrying about if
one of the test locales cannot be set.
........
r54649 | georg.brandl | 2007-04-01 14:29:15 -0700 (Sun, 01 Apr 2007) | 2 lines
Fix a lot of markup and meta-information glitches.
........
r54650 | georg.brandl | 2007-04-01 14:39:52 -0700 (Sun, 01 Apr 2007) | 2 lines
Another fix.
........
r54651 | georg.brandl | 2007-04-01 15:39:10 -0700 (Sun, 01 Apr 2007) | 2 lines
Lots of explicit class names for method and member descs.
........
r54652 | georg.brandl | 2007-04-01 15:40:12 -0700 (Sun, 01 Apr 2007) | 2 lines
Explicit class names.
........
r54653 | georg.brandl | 2007-04-01 15:47:31 -0700 (Sun, 01 Apr 2007) | 2 lines
Some semantic fixes.
........
r54654 | georg.brandl | 2007-04-01 16:29:10 -0700 (Sun, 01 Apr 2007) | 2 lines
Remove bogus entry.
........
r54655 | georg.brandl | 2007-04-01 16:31:30 -0700 (Sun, 01 Apr 2007) | 2 lines
Fix the class name of strings.
........
r54658 | raymond.hettinger | 2007-04-02 10:29:30 -0700 (Mon, 02 Apr 2007) | 1 line
SF #1693079: Cannot save empty array in shelve
........
r54663 | raymond.hettinger | 2007-04-02 15:54:21 -0700 (Mon, 02 Apr 2007) | 3 lines
Array module's buffer interface can now handle empty arrays.
........
r54664 | guido.van.rossum | 2007-04-02 16:55:37 -0700 (Mon, 02 Apr 2007) | 5 lines
Fix warnings about object.__init__() signature.
Two (test_array and test_descr) were bug IMO; the third (copy_reg)
is a work-around which recognizes that object.__init__() doesn't do
anything.
........
r54666 | raymond.hettinger | 2007-04-02 17:02:11 -0700 (Mon, 02 Apr 2007) | 1 line
SF 1602378 Clarify docstrings for bisect
........
r54668 | raymond.hettinger | 2007-04-02 18:39:43 -0700 (Mon, 02 Apr 2007) | 3 lines
SF #1382213: Tutorial section 9.5.1 ignores MRO for new-style classes
........
r54669 | matthias.klose | 2007-04-02 21:35:59 -0700 (Mon, 02 Apr 2007) | 4 lines
- Fix an off-by-one bug in locale.strxfrm().
patch taken from http://bugs.debian.org/416934.
........
r54671 | georg.brandl | 2007-04-03 00:04:27 -0700 (Tue, 03 Apr 2007) | 9 lines
Fix the strange case of
\begin{methoddesc}[NNTP]{...}
where
\ifx#1\@undefined ended up comparing N and N, therefore executing
the true part of the conditional, blowing up at \@undefined.
........
r54672 | facundo.batista | 2007-04-03 07:05:08 -0700 (Tue, 03 Apr 2007) | 4 lines
Now using unittest for the tests infraestructure. Also split the
tests in those who need the network, and that who doesn't.
........
r54673 | walter.doerwald | 2007-04-03 09:08:10 -0700 (Tue, 03 Apr 2007) | 4 lines
Move the functionality for catching warnings in test_warnings.py into a separate
class to that reusing the functionality in test_structmembers.py doesn't rerun
the tests from test_warnings.py.
........
r54674 | walter.doerwald | 2007-04-03 09:16:24 -0700 (Tue, 03 Apr 2007) | 2 lines
Document that CatchWarningTests is reused by test_structmembers.py.
........
r54675 | walter.doerwald | 2007-04-03 09:53:43 -0700 (Tue, 03 Apr 2007) | 4 lines
Add tests for the filename.
Test that the stacklevel is handled correctly.
........
r54676 | facundo.batista | 2007-04-03 10:29:48 -0700 (Tue, 03 Apr 2007) | 6 lines
Added a SSL server to test_socket_ssl.py to be able to test
locally. Now, it checks if have openssl available and run
those specific tests (it starts openssl at the beggining of
all the tests and then kills it at the end).
........
r54677 | walter.doerwald | 2007-04-03 11:33:29 -0700 (Tue, 03 Apr 2007) | 6 lines
Implement a contextmanager test.test_support.catch_warning that can
be used to catch the last warning issued by the warning framework.
Change test_warnings.py and test_structmembers.py to use this
new contextmanager.
........
r54678 | facundo.batista | 2007-04-03 14:15:34 -0700 (Tue, 03 Apr 2007) | 4 lines
Changed the whole structure of startup and checking if the
server is available. Hope to not get more false alarms.
........
r54681 | facundo.batista | 2007-04-04 07:10:40 -0700 (Wed, 04 Apr 2007) | 4 lines
Fixed the way that the .pem files are looked for, and changed
how to kill the process in win32 to use the _handle attribute.
........
r54682 | guido.van.rossum | 2007-04-04 10:43:02 -0700 (Wed, 04 Apr 2007) | 4 lines
Fix a race condition in this test -- instead of assuming that it will take
the test server thread at most 0.5 seconds to get ready, use an event
variable.
........
r54683 | collin.winter | 2007-04-04 11:14:17 -0700 (Wed, 04 Apr 2007) | 1 line
Clean up imports.
........
r54684 | collin.winter | 2007-04-04 11:16:24 -0700 (Wed, 04 Apr 2007) | 1 line
Stop using test_support.verify().
........
r54685 | martin.v.loewis | 2007-04-04 11:30:36 -0700 (Wed, 04 Apr 2007) | 2 lines
Bug #1686475: Support stat'ing open files on Windows again.
Will backport to 2.5.
........
r54687 | collin.winter | 2007-04-04 11:33:40 -0700 (Wed, 04 Apr 2007) | 1 line
Make test_getopt use unittest.
........
r54688 | collin.winter | 2007-04-04 11:36:30 -0700 (Wed, 04 Apr 2007) | 1 line
Make test_softspace use unittest.
........
r54689 | ziga.seilnacht | 2007-04-04 11:38:47 -0700 (Wed, 04 Apr 2007) | 2 lines
Fix WalkTests.test_traversal() on Windows. The cleanup in
MakedirTests.setUp() can now be removed.
........
r54695 | raymond.hettinger | 2007-04-05 11:00:03 -0700 (Thu, 05 Apr 2007) | 3 lines
Bug #1563759: struct.unpack doens't support buffer protocol objects
........
r54697 | collin.winter | 2007-04-05 13:05:07 -0700 (Thu, 05 Apr 2007) | 1 line
Convert test_long_future to use unittest.
........
r54698 | collin.winter | 2007-04-05 13:08:56 -0700 (Thu, 05 Apr 2007) | 1 line
Convert test_normalization to use unittest.
........
r54699 | andrew.kuchling | 2007-04-05 18:11:58 -0700 (Thu, 05 Apr 2007) | 1 line
Some grammar fixes
........
r54704 | collin.winter | 2007-04-06 12:27:40 -0700 (Fri, 06 Apr 2007) | 1 line
Convert test_stringprep to use unittest.
........
r54705 | collin.winter | 2007-04-06 12:32:32 -0700 (Fri, 06 Apr 2007) | 1 line
Import cleanup in test_crypt.
........
r54706 | collin.winter | 2007-04-06 13:00:05 -0700 (Fri, 06 Apr 2007) | 1 line
Convert test_gc to use unittest.
........
r54707 | collin.winter | 2007-04-06 13:03:11 -0700 (Fri, 06 Apr 2007) | 1 line
Convert test_module to use unittest.
........
r54711 | collin.winter | 2007-04-06 21:40:43 -0700 (Fri, 06 Apr 2007) | 1 line
Convert test_fileinput to use unittest.
........
r54712 | brett.cannon | 2007-04-07 21:29:32 -0700 (Sat, 07 Apr 2007) | 5 lines
Doc that file.next() has undefined behaviour when called on a file opened with
'w'. Closes bug #1569057.
To be backported once 2.5 branch is unfrozen.
........
r54726 | vinay.sajip | 2007-04-09 09:16:10 -0700 (Mon, 09 Apr 2007) | 1 line
Added optional timeout to SocketHandler.makeSocket (SF #1695948)
........
r54727 | ziga.seilnacht | 2007-04-09 12:10:29 -0700 (Mon, 09 Apr 2007) | 3 lines
Patch #1695862: remove old test directory that causes test_urllib failures
on Windows buildbots. The change is a one time fix and will be removed
after a successful buildbot run.
........
r54729 | facundo.batista | 2007-04-09 20:00:37 -0700 (Mon, 09 Apr 2007) | 3 lines
Minor fix to the tests pass ok even with -O.
........
r54730 | collin.winter | 2007-04-09 21:44:49 -0700 (Mon, 09 Apr 2007) | 1 line
Typo fix.
........
r54732 | facundo.batista | 2007-04-10 05:58:45 -0700 (Tue, 10 Apr 2007) | 5 lines
General clean-up. Lot of margin corrections, comments, some typos.
Exceptions now are raised in the new style. And a mockup class is
now also new style. Thanks Santiago Pereson.
........
r54741 | georg.brandl | 2007-04-10 14:39:38 -0700 (Tue, 10 Apr 2007) | 2 lines
Repair a duplicate label and some obsolete uses of \setindexsubitem.
........
r54746 | andrew.kuchling | 2007-04-11 06:39:00 -0700 (Wed, 11 Apr 2007) | 1 line
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
........
r54747 | andrew.kuchling | 2007-04-11 06:42:25 -0700 (Wed, 11 Apr 2007) | 1 line
Point readers at the patch submission instructions
........
r54748 | andrew.kuchling | 2007-04-11 06:47:13 -0700 (Wed, 11 Apr 2007) | 1 line
Describe undocumented third argument to touchline()
........
r54757 | georg.brandl | 2007-04-11 10:16:24 -0700 (Wed, 11 Apr 2007) | 3 lines
Add some missing NULL checks which trigger crashes on low-memory conditions.
Found by Victor Stinner. Will backport when 2.5 branch is unfrozen.
........
r54760 | raymond.hettinger | 2007-04-11 11:40:58 -0700 (Wed, 11 Apr 2007) | 1 line
SF 1191699: Make slices picklable
........
r54762 | georg.brandl | 2007-04-11 12:25:11 -0700 (Wed, 11 Apr 2007) | 2 lines
Exceptions are no longer old-style instances. Fix accordingly.
........
r54763 | georg.brandl | 2007-04-11 16:28:44 -0700 (Wed, 11 Apr 2007) | 2 lines
Repair missing spaces after \UNIX.
........
r54772 | raymond.hettinger | 2007-04-11 21:10:00 -0700 (Wed, 11 Apr 2007) | 1 line
SF 1193128: Let str.translate(None) be an identity transformation
........
r54784 | georg.brandl | 2007-04-12 00:01:19 -0700 (Thu, 12 Apr 2007) | 2 lines
Patch #1698951: clarify deprecation message in rexec and Bastion
........
r54785 | ziga.seilnacht | 2007-04-12 01:46:51 -0700 (Thu, 12 Apr 2007) | 2 lines
Patch #1695862: remove the cleanup code, now that Windows buildbots are green
again.
........
r54786 | walter.doerwald | 2007-04-12 03:35:00 -0700 (Thu, 12 Apr 2007) | 3 lines
Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the
first chunk fed to the decoder started with a BOM, but was longer than 3 bytes.
........
r54807 | barry.warsaw | 2007-04-13 11:47:14 -0700 (Fri, 13 Apr 2007) | 8 lines
Port r54805 from python25-maint branch:
Add code to read from master_fd in the parent, breaking when we get an OSError
(EIO can occur on Linux) or there's no more data to read. Without this,
test_pty.py can hang on the waitpid() because the child is blocking on the
stdout write. This will definitely happen on Mac OS X and could potentially
happen on other platforms. See the comment for details.
........
r54812 | kristjan.jonsson | 2007-04-13 15:07:33 -0700 (Fri, 13 Apr 2007) | 1 line
Fix a bug when using the __lltrace__ opcode tracer, and a problem sith signed chars in frameobject.c which can occur with opcodes > 127
........
r54814 | kristjan.jonsson | 2007-04-13 15:20:13 -0700 (Fri, 13 Apr 2007) | 1 line
Fix potential crash in path manipulation on windows
........
r54816 | trent.mick | 2007-04-13 16:22:05 -0700 (Fri, 13 Apr 2007) | 4 lines
Add the necessary dependency for the Windows VC6 build to ensure 'pythoncore'
is built before '_ctypes' is attempted.
Will backport to 2.5 once it is unfrozen for 2.5.1.
........
r54825 | neal.norwitz | 2007-04-13 22:25:50 -0700 (Fri, 13 Apr 2007) | 3 lines
When __slots__ are set to a unicode string, make it work the same as
setting a plain string, ie don't expand to single letter identifiers.
........
r54841 | neal.norwitz | 2007-04-16 00:37:55 -0700 (Mon, 16 Apr 2007) | 1 line
SF #1701207, Fix bogus assertion (and test it!)
........
r54844 | collin.winter | 2007-04-16 15:10:32 -0700 (Mon, 16 Apr 2007) | 1 line
Check the availability of the urlfetch resource earlier than before.
........
r54849 | martin.v.loewis | 2007-04-16 22:02:01 -0700 (Mon, 16 Apr 2007) | 2 lines
Add Travis Oliphant.
........
r54873 | brett.cannon | 2007-04-18 20:44:17 -0700 (Wed, 18 Apr 2007) | 2 lines
Silence a compiler warning about incompatible pointer types.
........
r54874 | neal.norwitz | 2007-04-18 22:52:37 -0700 (Wed, 18 Apr 2007) | 2 lines
SF #1703270, add missing declaration in readline.c to avoid compiler warning.
........
r54875 | armin.rigo | 2007-04-19 07:44:48 -0700 (Thu, 19 Apr 2007) | 8 lines
Revert r53997 as per
http://mail.python.org/pipermail/python-dev/2007-March/071796.html .
I've kept a couple of still-valid extra tests in test_descr, but didn't
bother to sort through the new comments and refactorings added in r53997
to see if some of them could be kept. If so, they could go in a
follow-up check-in.
........
r54876 | armin.rigo | 2007-04-19 07:56:48 -0700 (Thu, 19 Apr 2007) | 2 lines
Fix a usage of the dangerous pattern decref - modify field - incref.
........
r54884 | neal.norwitz | 2007-04-19 22:20:38 -0700 (Thu, 19 Apr 2007) | 9 lines
Add an optional address to copy the failure mails to.
Detect a conflict in the only file that should have outstanding changes
when this script is run. This doesn't matter on the trunk, but does
when run on a branch. Trunk always has the date set to today in
boilerplate.tex. Each time a release is cut with a different date,
a conflict occurs. (We could copy a known good version, but then
we would lose changes to this file.)
........
r54918 | georg.brandl | 2007-04-21 13:35:38 -0700 (Sat, 21 Apr 2007) | 3 lines
Bug #1704790: bind name "sys" locally in __del__ method so that it is
not cleared before __del__ is run.
........
r54920 | facundo.batista | 2007-04-21 18:18:56 -0700 (Sat, 21 Apr 2007) | 5 lines
Added tests for other methods of SSL object. Now we cover
all the object methods. This is the final step to close
the #451607 bug.
........
r54927 | facundo.batista | 2007-04-23 10:08:31 -0700 (Mon, 23 Apr 2007) | 5 lines
As specified in RFC 2616, 2xx code indicates that the client's
request was successfully received, understood, and accepted.
Now in these cases no error is raised. Also fixed tests.
........
r54929 | collin.winter | 2007-04-23 20:43:46 -0700 (Mon, 23 Apr 2007) | 1 line
Convert PyUnit -> unittest.
........
r54931 | collin.winter | 2007-04-23 21:09:52 -0700 (Mon, 23 Apr 2007) | 1 line
Remove code that hasn't been called in years.
........
r54932 | neal.norwitz | 2007-04-23 21:53:12 -0700 (Mon, 23 Apr 2007) | 1 line
Fix SF #1703110, Incorrect example for add_password() (use uri, not host)
........
r54934 | georg.brandl | 2007-04-24 03:36:42 -0700 (Tue, 24 Apr 2007) | 2 lines
Some new year updates.
........
r54938 | facundo.batista | 2007-04-24 06:54:38 -0700 (Tue, 24 Apr 2007) | 4 lines
Added a comment about last change in urllib2.py (all 2xx responses
are ok now).
........
r54939 | georg.brandl | 2007-04-24 08:10:09 -0700 (Tue, 24 Apr 2007) | 2 lines
Bug #1705717: error in sys.argv docs.
........
r54941 | georg.brandl | 2007-04-24 08:27:13 -0700 (Tue, 24 Apr 2007) | 4 lines
Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file
(as opposed to the command line) will now write file names ending in
".cpp" too.
........
r54944 | raymond.hettinger | 2007-04-24 15:13:43 -0700 (Tue, 24 Apr 2007) | 1 line
Fix markup
........
r54945 | kristjan.jonsson | 2007-04-24 17:10:50 -0700 (Tue, 24 Apr 2007) | 1 line
Merge change 54909 from release25-maint: Fix several minor issues discovered using code analysis in VisualStudio 2005 Team Edition
........
r54947 | kristjan.jonsson | 2007-04-24 17:17:39 -0700 (Tue, 24 Apr 2007) | 1 line
Make pythoncore compile cleanly with VisualStudio 2005. Used an explicit typecast to get a 64 bit integer, and undefined the Yield macro that conflicts with winbase.h
........
r54948 | kristjan.jonsson | 2007-04-24 17:19:26 -0700 (Tue, 24 Apr 2007) | 1 line
Remove obsolete comment. Importing of .dll files has been discontinued, only .pyd files supported on windows now.
........
r54949 | georg.brandl | 2007-04-24 23:24:59 -0700 (Tue, 24 Apr 2007) | 2 lines
Patch #1698768: updated the "using Python on the Mac" intro.
........
r54951 | georg.brandl | 2007-04-24 23:25:55 -0700 (Tue, 24 Apr 2007) | 2 lines
Markup fix.
........
r54953 | neal.norwitz | 2007-04-24 23:30:05 -0700 (Tue, 24 Apr 2007) | 3 lines
Whitespace normalization. Ugh, we really need to do this more often.
You might want to review this change as it's my first time. Be gentle. :-)
........
r54956 | collin.winter | 2007-04-25 10:29:52 -0700 (Wed, 25 Apr 2007) | 1 line
Standardize on test.test_support.run_unittest() (as opposed to a mix of run_unittest() and run_suite()). Also, add functionality to run_unittest() that admits usage of unittest.TestLoader.loadTestsFromModule().
........
r54957 | collin.winter | 2007-04-25 10:37:35 -0700 (Wed, 25 Apr 2007) | 1 line
Remove functionality from test_datetime.test_main() that does reference count checking; 'regrtest.py -R' is the way to do this kind of testing.
........
r54958 | collin.winter | 2007-04-25 10:57:53 -0700 (Wed, 25 Apr 2007) | 1 line
Change test_support.have_unicode to use True/False instead of 1/0.
........
r54959 | tim.peters | 2007-04-25 11:47:18 -0700 (Wed, 25 Apr 2007) | 2 lines
Whitespace normalization.
........
r54960 | tim.peters | 2007-04-25 11:48:35 -0700 (Wed, 25 Apr 2007) | 2 lines
Set missing svn:eol-style property on text files.
........
r54961 | collin.winter | 2007-04-25 11:54:36 -0700 (Wed, 25 Apr 2007) | 1 line
Import and raise statement cleanup.
........
r54969 | collin.winter | 2007-04-25 13:41:34 -0700 (Wed, 25 Apr 2007) | 1 line
Convert test_ossaudiodev to use unittest.
........
r54974 | collin.winter | 2007-04-25 14:50:25 -0700 (Wed, 25 Apr 2007) | 1 line
Fix an issue related to the unittest conversion.
........
r54979 | fred.drake | 2007-04-25 21:42:19 -0700 (Wed, 25 Apr 2007) | 1 line
fix some markup errors
........
r54982 | kristjan.jonsson | 2007-04-26 02:15:08 -0700 (Thu, 26 Apr 2007) | 1 line
Export function sanitize_the_mode from fileobject.c as _PyFile_SanitizeMode(). Use this function in posixmodule.c when implementing fdopen(). This fixes test_subprocess.py for a VisualStudio 2005 compile.
........
r54983 | kristjan.jonsson | 2007-04-26 06:44:16 -0700 (Thu, 26 Apr 2007) | 1 line
The locale "En" appears not to be valid on windows underi VisualStudio.2005. Added "English" to the test_locale.py to make the testsuite pass for that build
........
r54984 | steve.holden | 2007-04-26 07:23:12 -0700 (Thu, 26 Apr 2007) | 1 line
Minor wording change on slicing aide-memoire.
........
r54985 | kristjan.jonsson | 2007-04-26 08:24:54 -0700 (Thu, 26 Apr 2007) | 1 line
Accomodate 64 bit time_t in the _bsddb module.
........
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 27 Apr 2007 19:54:29 +0000 |
| parents | f29f1a8b7869 |
| children | 15b810e21fe9 |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* System module */ |
| 3 | |
| 4 /* | |
| 5 Various bits of information used by the interpreter are collected in | |
| 6 module 'sys'. | |
| 86 | 7 Function member: |
|
2586
ae131b8b4e31
fix comment about exit()
Guido van Rossum <guido@python.org>
parents:
2421
diff
changeset
|
8 - exit(sts): raise SystemExit |
| 6 | 9 Data members: |
| 10 - stdin, stdout, stderr: standard file objects | |
| 86 | 11 - modules: the table of modules (dictionary) |
| 6 | 12 - path: module search path (list of strings) |
| 86 | 13 - argv: script arguments (list of strings) |
| 14 - ps1, ps2: optional primary and secondary prompts (strings) | |
| 6 | 15 */ |
| 16 | |
| 5372 | 17 #include "Python.h" |
|
35742
1c4d192f1568
Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
35673
diff
changeset
|
18 #include "code.h" |
|
15487
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
19 #include "frameobject.h" |
|
28556
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
20 #include "eval.h" |
| 86 | 21 |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
22 #include "osdefs.h" |
| 86 | 23 |
|
25666
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
24 #ifdef MS_WINDOWS |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
25 #define WIN32_LEAN_AND_MEAN |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
26 #include "windows.h" |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
27 #endif /* MS_WINDOWS */ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
28 |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4256
diff
changeset
|
29 #ifdef MS_COREDLL |
|
3490
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
30 extern void *PyWin_DLLhModule; |
|
6352
b62a7a59414e
Get DLL version from a variable.
Guido van Rossum <guido@python.org>
parents:
5955
diff
changeset
|
31 /* A string loaded from the DLL at startup: */ |
|
b62a7a59414e
Get DLL version from a variable.
Guido van Rossum <guido@python.org>
parents:
5955
diff
changeset
|
32 extern const char *PyWin_DLLVersionString; |
|
3490
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
33 #endif |
|
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
34 |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
35 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
36 #include <unixlib.h> |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
37 #endif |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
38 |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
39 #ifdef MS_WINDOWS |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
40 #include <windows.h> |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
41 #endif |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
42 |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
43 #ifdef HAVE_LANGINFO_H |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
44 #include <locale.h> |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
45 #include <langinfo.h> |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
46 #endif |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
47 |
| 5372 | 48 PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
49 PySys_GetObject(char *name) |
| 6 | 50 { |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
51 PyThreadState *tstate = PyThreadState_GET(); |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
52 PyObject *sd = tstate->interp->sysdict; |
|
11374
66216f32403d
In PySys_GetObject(), it's possible that tstate->interp->sysdict is
Guido van Rossum <guido@python.org>
parents:
9964
diff
changeset
|
53 if (sd == NULL) |
|
66216f32403d
In PySys_GetObject(), it's possible that tstate->interp->sysdict is
Guido van Rossum <guido@python.org>
parents:
9964
diff
changeset
|
54 return NULL; |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
55 return PyDict_GetItemString(sd, name); |
| 6 | 56 } |
| 57 | |
| 58 FILE * | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
59 PySys_GetFile(char *name, FILE *def) |
| 6 | 60 { |
| 61 FILE *fp = NULL; | |
| 5372 | 62 PyObject *v = PySys_GetObject(name); |
| 63 if (v != NULL && PyFile_Check(v)) | |
| 64 fp = PyFile_AsFile(v); | |
| 6 | 65 if (fp == NULL) |
| 66 fp = def; | |
| 67 return fp; | |
| 68 } | |
| 69 | |
| 70 int | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
71 PySys_SetObject(char *name, PyObject *v) |
| 6 | 72 { |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
73 PyThreadState *tstate = PyThreadState_GET(); |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
74 PyObject *sd = tstate->interp->sysdict; |
|
631
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
75 if (v == NULL) { |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
76 if (PyDict_GetItemString(sd, name) == NULL) |
|
631
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
77 return 0; |
|
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
78 else |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
79 return PyDict_DelItemString(sd, name); |
|
631
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
80 } |
| 6 | 81 else |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
82 return PyDict_SetItemString(sd, name, v); |
| 6 | 83 } |
| 84 | |
| 5372 | 85 static PyObject * |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
86 sys_displayhook(PyObject *self, PyObject *o) |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
87 { |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
88 PyObject *outf; |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
89 PyInterpreterState *interp = PyThreadState_GET()->interp; |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
90 PyObject *modules = interp->modules; |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
91 PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
92 |
|
18805
4462c57f6c94
Patch number #422106 by Greg Ball, to fix segmentation
Moshe Zadka <moshez@math.huji.ac.il>
parents:
18689
diff
changeset
|
93 if (builtins == NULL) { |
|
4462c57f6c94
Patch number #422106 by Greg Ball, to fix segmentation
Moshe Zadka <moshez@math.huji.ac.il>
parents:
18689
diff
changeset
|
94 PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); |
|
4462c57f6c94
Patch number #422106 by Greg Ball, to fix segmentation
Moshe Zadka <moshez@math.huji.ac.il>
parents:
18689
diff
changeset
|
95 return NULL; |
|
4462c57f6c94
Patch number #422106 by Greg Ball, to fix segmentation
Moshe Zadka <moshez@math.huji.ac.il>
parents:
18689
diff
changeset
|
96 } |
|
4462c57f6c94
Patch number #422106 by Greg Ball, to fix segmentation
Moshe Zadka <moshez@math.huji.ac.il>
parents:
18689
diff
changeset
|
97 |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
98 /* Print value except if None */ |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
99 /* After printing, also assign to '_' */ |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
100 /* Before, set '_' to None to avoid recursion */ |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
101 if (o == Py_None) { |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
102 Py_INCREF(Py_None); |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
103 return Py_None; |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
104 } |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
105 if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
106 return NULL; |
|
15812
a563eec46c1a
stdout is sometimes a macro; use "outf" instead.
Greg Stein <gstein@lyra.org>
parents:
15811
diff
changeset
|
107 outf = PySys_GetObject("stdout"); |
|
a563eec46c1a
stdout is sometimes a macro; use "outf" instead.
Greg Stein <gstein@lyra.org>
parents:
15811
diff
changeset
|
108 if (outf == NULL) { |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
109 PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
110 return NULL; |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
111 } |
|
15812
a563eec46c1a
stdout is sometimes a macro; use "outf" instead.
Greg Stein <gstein@lyra.org>
parents:
15811
diff
changeset
|
112 if (PyFile_WriteObject(o, outf, 0) != 0) |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
113 return NULL; |
|
40799
04f5cbc74424
Kill off softspace completely (except in formatter.py which seems to have
Guido van Rossum <guido@python.org>
parents:
40788
diff
changeset
|
114 if (PyFile_WriteString("\n", outf) != 0) |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
115 return NULL; |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
116 if (PyObject_SetAttrString(builtins, "_", o) != 0) |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
117 return NULL; |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
118 Py_INCREF(Py_None); |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
119 return Py_None; |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
120 } |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
121 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
122 PyDoc_STRVAR(displayhook_doc, |
| 17164 | 123 "displayhook(object) -> None\n" |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
124 "\n" |
|
36814
7a30dc2af329
Fix minor docstring typo.
Brett Cannon <bcannon@gmail.com>
parents:
36521
diff
changeset
|
125 "Print an object to sys.stdout and also save it in __builtin__.\n" |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
126 ); |
| 17164 | 127 |
| 128 static PyObject * | |
| 129 sys_excepthook(PyObject* self, PyObject* args) | |
| 130 { | |
| 131 PyObject *exc, *value, *tb; | |
|
20655
7344687bf2c0
Convert getrefcount() to METH_O, and sys_excepthook() to use
Fred Drake <fdrake@acm.org>
parents:
20247
diff
changeset
|
132 if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb)) |
| 17164 | 133 return NULL; |
| 134 PyErr_Display(exc, value, tb); | |
| 135 Py_INCREF(Py_None); | |
| 136 return Py_None; | |
| 137 } | |
| 138 | |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
139 PyDoc_STRVAR(excepthook_doc, |
| 17164 | 140 "excepthook(exctype, value, traceback) -> None\n" |
| 141 "\n" | |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
142 "Handle an exception by displaying it with a traceback on sys.stderr.\n" |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
143 ); |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
144 |
|
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
145 static PyObject * |
|
28119
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
146 sys_exc_info(PyObject *self, PyObject *noargs) |
|
5405
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
147 { |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
148 PyThreadState *tstate; |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
149 tstate = PyThreadState_GET(); |
|
5405
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
150 return Py_BuildValue( |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
151 "(OOO)", |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
152 tstate->exc_type != NULL ? tstate->exc_type : Py_None, |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
153 tstate->exc_value != NULL ? tstate->exc_value : Py_None, |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
154 tstate->exc_traceback != NULL ? |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
155 tstate->exc_traceback : Py_None); |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
156 } |
|
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
157 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
158 PyDoc_STRVAR(exc_info_doc, |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
159 "exc_info() -> (type, value, traceback)\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
160 \n\ |
|
28119
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
161 Return information about the most recent exception caught by an except\n\ |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
162 clause in the current stack frame or in an older stack frame." |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
163 ); |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
164 |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
165 static PyObject * |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
166 sys_exc_clear(PyObject *self, PyObject *noargs) |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
167 { |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
168 PyThreadState *tstate = PyThreadState_GET(); |
|
28119
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
169 PyObject *tmp_type, *tmp_value, *tmp_tb; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
170 tmp_type = tstate->exc_type; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
171 tmp_value = tstate->exc_value; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
172 tmp_tb = tstate->exc_traceback; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
173 tstate->exc_type = NULL; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
174 tstate->exc_value = NULL; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
175 tstate->exc_traceback = NULL; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
176 Py_XDECREF(tmp_type); |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
177 Py_XDECREF(tmp_value); |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
178 Py_XDECREF(tmp_tb); |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
179 Py_INCREF(Py_None); |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
180 return Py_None; |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
181 } |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
182 |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
183 PyDoc_STRVAR(exc_clear_doc, |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
184 "exc_clear() -> None\n\ |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
185 \n\ |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
186 Clear global information on the current exception. Subsequent calls to\n\ |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
187 exc_info() will return (None,None,None) until another exception is raised\n\ |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
188 in the current thread or the execution stack returns to a frame where\n\ |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
189 another exception is being handled." |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
190 ); |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
191 |
|
5405
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
192 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
193 sys_exit(PyObject *self, PyObject *args) |
| 6 | 194 { |
|
22604
3f4b2f93e8b5
Change sys_exit to use METH_VARARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
22531
diff
changeset
|
195 PyObject *exit_code = 0; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
196 if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code)) |
|
22604
3f4b2f93e8b5
Change sys_exit to use METH_VARARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
22531
diff
changeset
|
197 return NULL; |
|
549
4efff6cea90f
Raise SystemExit instead of calling goaway().
Guido van Rossum <guido@python.org>
parents:
476
diff
changeset
|
198 /* Raise SystemExit so callers may catch it or clean up. */ |
|
22604
3f4b2f93e8b5
Change sys_exit to use METH_VARARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
22531
diff
changeset
|
199 PyErr_SetObject(PyExc_SystemExit, exit_code); |
|
549
4efff6cea90f
Raise SystemExit instead of calling goaway().
Guido van Rossum <guido@python.org>
parents:
476
diff
changeset
|
200 return NULL; |
| 6 | 201 } |
| 202 | |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
203 PyDoc_STRVAR(exit_doc, |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
204 "exit([status])\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
205 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
206 Exit the interpreter by raising SystemExit(status).\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
207 If the status is omitted or None, it defaults to zero (i.e., success).\n\ |
|
22531
ef314b37e260
backport nascheme's checkin of
Michael W. Hudson <mwh@python.net>
parents:
22119
diff
changeset
|
208 If the status is numeric, it will be used as the system exit status.\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
209 If it is another kind of object, it will be printed and the system\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
210 exit status will be one (i.e., failure)." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
211 ); |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
212 |
|
20943
e4d380f5f297
Include sys_getdefaultencoding in #ifdef Py_USING_UNICODE. Fixes #479571.
Martin v. Löwis <martin@v.loewis.de>
parents:
20655
diff
changeset
|
213 #ifdef Py_USING_UNICODE |
|
e4d380f5f297
Include sys_getdefaultencoding in #ifdef Py_USING_UNICODE. Fixes #479571.
Martin v. Löwis <martin@v.loewis.de>
parents:
20655
diff
changeset
|
214 |
| 5372 | 215 static PyObject * |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
216 sys_getdefaultencoding(PyObject *self) |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
217 { |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
218 return PyString_FromString(PyUnicode_GetDefaultEncoding()); |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
219 } |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
220 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
221 PyDoc_STRVAR(getdefaultencoding_doc, |
|
12877
78231bbe605d
Marc-Andre Lemburg <mal@lemburg.com>:
Marc-André Lemburg <mal@egenix.com>
parents:
12649
diff
changeset
|
222 "getdefaultencoding() -> string\n\ |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
223 \n\ |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
224 Return the current default string encoding used by the Unicode \n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
225 implementation." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
226 ); |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
227 |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
228 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
229 sys_setdefaultencoding(PyObject *self, PyObject *args) |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
230 { |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
231 char *encoding; |
|
12877
78231bbe605d
Marc-Andre Lemburg <mal@lemburg.com>:
Marc-André Lemburg <mal@egenix.com>
parents:
12649
diff
changeset
|
232 if (!PyArg_ParseTuple(args, "s:setdefaultencoding", &encoding)) |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
233 return NULL; |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
234 if (PyUnicode_SetDefaultEncoding(encoding)) |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
235 return NULL; |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
236 Py_INCREF(Py_None); |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
237 return Py_None; |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
238 } |
|
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
239 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
240 PyDoc_STRVAR(setdefaultencoding_doc, |
|
12877
78231bbe605d
Marc-Andre Lemburg <mal@lemburg.com>:
Marc-André Lemburg <mal@egenix.com>
parents:
12649
diff
changeset
|
241 "setdefaultencoding(encoding)\n\ |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
242 \n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
243 Set the current default string encoding used by the Unicode implementation." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
244 ); |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
245 |
|
28174
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
246 static PyObject * |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
247 sys_getfilesystemencoding(PyObject *self) |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
248 { |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
249 if (Py_FileSystemDefaultEncoding) |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
250 return PyString_FromString(Py_FileSystemDefaultEncoding); |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
251 Py_INCREF(Py_None); |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
252 return Py_None; |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
253 } |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
254 |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
255 PyDoc_STRVAR(getfilesystemencoding_doc, |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
256 "getfilesystemencoding() -> string\n\ |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
257 \n\ |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
258 Return the encoding used to convert Unicode filenames in\n\ |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
259 operating system filenames." |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
260 ); |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
261 |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
262 #endif |
|
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
263 |
|
40484
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
264 |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
265 static PyObject * |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
266 sys_intern(PyObject *self, PyObject *args) |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
267 { |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
268 PyObject *s; |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
269 if (!PyArg_ParseTuple(args, "S:intern", &s)) |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
270 return NULL; |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
271 if (!PyString_CheckExact(s)) { |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
272 PyErr_SetString(PyExc_TypeError, |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
273 "can't intern subclass of string"); |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
274 return NULL; |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
275 } |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
276 Py_INCREF(s); |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
277 PyString_InternInPlace(&s); |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
278 return s; |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
279 } |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
280 |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
281 PyDoc_STRVAR(intern_doc, |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
282 "intern(string) -> string\n\ |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
283 \n\ |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
284 ``Intern'' the given string. This enters the string in the (global)\n\ |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
285 table of interned strings whose purpose is to speed up dictionary lookups.\n\ |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
286 Return the string itself or the previously interned string object with the\n\ |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
287 same value."); |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
288 |
|
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
289 |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
290 /* |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
291 * Cached interned string objects used for calling the profile and |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
292 * trace functions. Initialized by trace_init(). |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
293 */ |
|
31796
1c117dbb2def
Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents:
30108
diff
changeset
|
294 static PyObject *whatstrings[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
295 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
296 static int |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
297 trace_init(void) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
298 { |
|
31796
1c117dbb2def
Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents:
30108
diff
changeset
|
299 static char *whatnames[7] = {"call", "exception", "line", "return", |
|
1c117dbb2def
Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents:
30108
diff
changeset
|
300 "c_call", "c_exception", "c_return"}; |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
301 PyObject *name; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
302 int i; |
|
31796
1c117dbb2def
Enable the profiling of C functions (builtins and extensions)
Nicholas Bastin <nick.bastin@gmail.com>
parents:
30108
diff
changeset
|
303 for (i = 0; i < 7; ++i) { |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
304 if (whatstrings[i] == NULL) { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
305 name = PyString_InternFromString(whatnames[i]); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
306 if (name == NULL) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
307 return -1; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
308 whatstrings[i] = name; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
309 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
310 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
311 return 0; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
312 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
313 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
314 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
315 static PyObject * |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
316 call_trampoline(PyThreadState *tstate, PyObject* callback, |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
317 PyFrameObject *frame, int what, PyObject *arg) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
318 { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
319 PyObject *args = PyTuple_New(3); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
320 PyObject *whatstr; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
321 PyObject *result; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
322 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
323 if (args == NULL) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
324 return NULL; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
325 Py_INCREF(frame); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
326 whatstr = whatstrings[what]; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
327 Py_INCREF(whatstr); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
328 if (arg == NULL) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
329 arg = Py_None; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
330 Py_INCREF(arg); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
331 PyTuple_SET_ITEM(args, 0, (PyObject *)frame); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
332 PyTuple_SET_ITEM(args, 1, whatstr); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
333 PyTuple_SET_ITEM(args, 2, arg); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
334 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
335 /* call the Python-level function */ |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
336 PyFrame_FastToLocals(frame); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
337 result = PyEval_CallObject(callback, args); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
338 PyFrame_LocalsToFast(frame, 1); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
339 if (result == NULL) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
340 PyTraceBack_Here(frame); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
341 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
342 /* cleanup */ |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
343 Py_DECREF(args); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
344 return result; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
345 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
346 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
347 static int |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
348 profile_trampoline(PyObject *self, PyFrameObject *frame, |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
349 int what, PyObject *arg) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
350 { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
351 PyThreadState *tstate = frame->f_tstate; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
352 PyObject *result; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
353 |
|
20247
a4d328d50897
Rationalize the events passed to the profiler (no changes for the tracer).
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
354 if (arg == NULL) |
|
a4d328d50897
Rationalize the events passed to the profiler (no changes for the tracer).
Fred Drake <fdrake@acm.org>
parents:
19343
diff
changeset
|
355 arg = Py_None; |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
356 result = call_trampoline(tstate, self, frame, what, arg); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
357 if (result == NULL) { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
358 PyEval_SetProfile(NULL, NULL); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
359 return -1; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
360 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
361 Py_DECREF(result); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
362 return 0; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
363 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
364 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
365 static int |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
366 trace_trampoline(PyObject *self, PyFrameObject *frame, |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
367 int what, PyObject *arg) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
368 { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
369 PyThreadState *tstate = frame->f_tstate; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
370 PyObject *callback; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
371 PyObject *result; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
372 |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
373 if (what == PyTrace_CALL) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
374 callback = self; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
375 else |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
376 callback = frame->f_trace; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
377 if (callback == NULL) |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
378 return 0; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
379 result = call_trampoline(tstate, callback, frame, what, arg); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
380 if (result == NULL) { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
381 PyEval_SetTrace(NULL, NULL); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
382 Py_XDECREF(frame->f_trace); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
383 frame->f_trace = NULL; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
384 return -1; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
385 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
386 if (result != Py_None) { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
387 PyObject *temp = frame->f_trace; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
388 frame->f_trace = NULL; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
389 Py_XDECREF(temp); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
390 frame->f_trace = result; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
391 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
392 else { |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
393 Py_DECREF(result); |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
394 } |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
395 return 0; |
|
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
396 } |
|
18136
4cb34314bd97
Instead of initializing & interning the strings passed to the profile
Fred Drake <fdrake@acm.org>
parents:
17396
diff
changeset
|
397 |
|
12649
c92668766f5d
M.-A. Lemburg <mal@lemburg.com>:
Fred Drake <fdrake@acm.org>
parents:
12398
diff
changeset
|
398 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
399 sys_settrace(PyObject *self, PyObject *args) |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
400 { |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
401 if (trace_init() == -1) |
|
18136
4cb34314bd97
Instead of initializing & interning the strings passed to the profile
Fred Drake <fdrake@acm.org>
parents:
17396
diff
changeset
|
402 return NULL; |
| 5372 | 403 if (args == Py_None) |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
404 PyEval_SetTrace(NULL, NULL); |
|
788
ba4ec13c0f9f
Fix reference counts of sys_trace and sys_profile
Guido van Rossum <guido@python.org>
parents:
710
diff
changeset
|
405 else |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
406 PyEval_SetTrace(trace_trampoline, args); |
| 5372 | 407 Py_INCREF(Py_None); |
| 408 return Py_None; | |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
409 } |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
410 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
411 PyDoc_STRVAR(settrace_doc, |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
412 "settrace(function)\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
413 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
414 Set the global debug tracing function. It will be called on each\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
415 function call. See the debugger chapter in the library manual." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
416 ); |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
417 |
| 5372 | 418 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
419 sys_setprofile(PyObject *self, PyObject *args) |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
420 { |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
421 if (trace_init() == -1) |
|
18136
4cb34314bd97
Instead of initializing & interning the strings passed to the profile
Fred Drake <fdrake@acm.org>
parents:
17396
diff
changeset
|
422 return NULL; |
| 5372 | 423 if (args == Py_None) |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
424 PyEval_SetProfile(NULL, NULL); |
|
788
ba4ec13c0f9f
Fix reference counts of sys_trace and sys_profile
Guido van Rossum <guido@python.org>
parents:
710
diff
changeset
|
425 else |
|
18326
e427afb5637f
Revise the interface to the profiling and tracing support for the
Fred Drake <fdrake@acm.org>
parents:
18298
diff
changeset
|
426 PyEval_SetProfile(profile_trampoline, args); |
| 5372 | 427 Py_INCREF(Py_None); |
| 428 return Py_None; | |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
429 } |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
430 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
431 PyDoc_STRVAR(setprofile_doc, |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
432 "setprofile(function)\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
433 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
434 Set the profiling function. It will be called on each function call\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
435 and return. See the profiler chapter in the library manual." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
436 ); |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
437 |
| 5372 | 438 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
439 sys_setcheckinterval(PyObject *self, PyObject *args) |
|
2093
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
440 { |
|
25108
3a26e352f0a6
replace thread state objects' ticker and checkinterval fields with two
Skip Montanaro <skip@pobox.com>
parents:
25099
diff
changeset
|
441 if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval)) |
|
2093
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
442 return NULL; |
| 5372 | 443 Py_INCREF(Py_None); |
| 444 return Py_None; | |
|
2093
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
445 } |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
446 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
447 PyDoc_STRVAR(setcheckinterval_doc, |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
448 "setcheckinterval(n)\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
449 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
450 Tell the Python interpreter to check for asynchronous events every\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
451 n instructions. This also affects how often thread switches occur." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
452 ); |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
453 |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
454 static PyObject * |
|
29765
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
455 sys_getcheckinterval(PyObject *self, PyObject *args) |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
456 { |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
457 return PyInt_FromLong(_Py_CheckInterval); |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
458 } |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
459 |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
460 PyDoc_STRVAR(getcheckinterval_doc, |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
461 "getcheckinterval() -> current check interval; see setcheckinterval()." |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
462 ); |
|
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
463 |
|
32301
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
464 #ifdef WITH_TSC |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
465 static PyObject * |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
466 sys_settscdump(PyObject *self, PyObject *args) |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
467 { |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
468 int bool; |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
469 PyThreadState *tstate = PyThreadState_Get(); |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
470 |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
471 if (!PyArg_ParseTuple(args, "i:settscdump", &bool)) |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
472 return NULL; |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
473 if (bool) |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
474 tstate->interp->tscdump = 1; |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
475 else |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
476 tstate->interp->tscdump = 0; |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
477 Py_INCREF(Py_None); |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
478 return Py_None; |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
479 |
|
32301
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
480 } |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
481 |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
482 PyDoc_STRVAR(settscdump_doc, |
|
32301
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
483 "settscdump(bool)\n\ |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
484 \n\ |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
485 If true, tell the Python interpreter to dump VM measurements to\n\ |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
486 stderr. If false, turn off dump. The measurements are based on the\n\ |
| 33104 | 487 processor's time-stamp counter." |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
488 ); |
|
32344
748129e6e108
Remove compiler warning
Neal Norwitz <nnorwitz@gmail.com>
parents:
32301
diff
changeset
|
489 #endif /* TSC */ |
|
32301
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
490 |
|
29765
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
491 static PyObject * |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
492 sys_setrecursionlimit(PyObject *self, PyObject *args) |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
493 { |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
494 int new_limit; |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
495 if (!PyArg_ParseTuple(args, "i:setrecursionlimit", &new_limit)) |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
496 return NULL; |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
497 if (new_limit <= 0) { |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
498 PyErr_SetString(PyExc_ValueError, |
|
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
499 "recursion limit must be positive"); |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
500 return NULL; |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
501 } |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
502 Py_SetRecursionLimit(new_limit); |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
503 Py_INCREF(Py_None); |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
504 return Py_None; |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
505 } |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
506 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
507 PyDoc_STRVAR(setrecursionlimit_doc, |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
508 "setrecursionlimit(n)\n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
509 \n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
510 Set the maximum depth of the Python interpreter stack to n. This\n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
511 limit prevents infinite recursion from causing an overflow of the C\n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
512 stack and crashing Python. The highest possible limit is platform-\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
513 dependent." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
514 ); |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
515 |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
516 static PyObject * |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
517 sys_getrecursionlimit(PyObject *self) |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
518 { |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
519 return PyInt_FromLong(Py_GetRecursionLimit()); |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
520 } |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
521 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
522 PyDoc_STRVAR(getrecursionlimit_doc, |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
523 "getrecursionlimit()\n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
524 \n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
525 Return the current value of the recursion limit, the maximum depth\n\ |
|
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
526 of the Python interpreter stack. This limit prevents infinite\n\ |
|
24013
71f13cf4f9e2
Got rid of an extraneous semicolon.
Jack Jansen <jack.jansen@cwi.nl>
parents:
23947
diff
changeset
|
527 recursion from causing an overflow of the C stack and crashing Python." |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
528 ); |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
529 |
|
25666
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
530 #ifdef MS_WINDOWS |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
531 PyDoc_STRVAR(getwindowsversion_doc, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
532 "getwindowsversion()\n\ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
533 \n\ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
534 Return information about the running version of Windows.\n\ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
535 The result is a tuple of (major, minor, build, platform, text)\n\ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
536 All elements are numbers, except text which is a string.\n\ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
537 Platform may be 0 for win32s, 1 for Windows 9x/ME, 2 for Windows NT/2000/XP\n\ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
538 " |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
539 ); |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
540 |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
541 static PyObject * |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
542 sys_getwindowsversion(PyObject *self) |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
543 { |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
544 OSVERSIONINFO ver; |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
545 ver.dwOSVersionInfoSize = sizeof(ver); |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
546 if (!GetVersionEx(&ver)) |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
547 return PyErr_SetFromWindowsErr(0); |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
548 return Py_BuildValue("HHHHs", |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
549 ver.dwMajorVersion, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
550 ver.dwMinorVersion, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
551 ver.dwBuildNumber, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
552 ver.dwPlatformId, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
553 ver.szCSDVersion); |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
554 } |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
555 |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
556 #endif /* MS_WINDOWS */ |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
557 |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
558 #ifdef HAVE_DLOPEN |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
559 static PyObject * |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
560 sys_setdlopenflags(PyObject *self, PyObject *args) |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
561 { |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
562 int new_val; |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
563 PyThreadState *tstate = PyThreadState_GET(); |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
564 if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val)) |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
565 return NULL; |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
566 if (!tstate) |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
567 return NULL; |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
568 tstate->interp->dlopenflags = new_val; |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
569 Py_INCREF(Py_None); |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
570 return Py_None; |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
571 } |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
572 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
573 PyDoc_STRVAR(setdlopenflags_doc, |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
574 "setdlopenflags(n) -> None\n\ |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
575 \n\ |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
576 Set the flags that will be used for dlopen() calls. Among other\n\ |
|
21833
070d392042e3
Fix spelling mistakes. Bugfix candidates.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21712
diff
changeset
|
577 things, this will enable a lazy resolving of symbols when importing\n\ |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
578 a module, if called as sys.setdlopenflags(0)\n\ |
|
21833
070d392042e3
Fix spelling mistakes. Bugfix candidates.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21712
diff
changeset
|
579 To share symbols across extension modules, call as\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
580 sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)" |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
581 ); |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
582 |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
583 static PyObject * |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
584 sys_getdlopenflags(PyObject *self, PyObject *args) |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
585 { |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
586 PyThreadState *tstate = PyThreadState_GET(); |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
587 if (!tstate) |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
588 return NULL; |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
589 return PyInt_FromLong(tstate->interp->dlopenflags); |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
590 } |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
591 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
592 PyDoc_STRVAR(getdlopenflags_doc, |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
593 "getdlopenflags() -> int\n\ |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
594 \n\ |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
595 Return the current value of the flags that are used for dlopen()\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
596 calls. The flag constants are defined in the dl module." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
597 ); |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
598 #endif |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
599 |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
600 #ifdef USE_MALLOPT |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
601 /* Link with -lmalloc (or -lmpc) on an SGI */ |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
602 #include <malloc.h> |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
603 |
| 5372 | 604 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
605 sys_mdebug(PyObject *self, PyObject *args) |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
606 { |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
607 int flag; |
|
12136
9b9abde032b3
Use modern PyArg_ParseTuple style, with function names.
Guido van Rossum <guido@python.org>
parents:
11882
diff
changeset
|
608 if (!PyArg_ParseTuple(args, "i:mdebug", &flag)) |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
609 return NULL; |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
610 mallopt(M_DEBUG, flag); |
| 5372 | 611 Py_INCREF(Py_None); |
| 612 return Py_None; | |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
613 } |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
614 #endif /* USE_MALLOPT */ |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
615 |
| 5372 | 616 static PyObject * |
|
20655
7344687bf2c0
Convert getrefcount() to METH_O, and sys_excepthook() to use
Fred Drake <fdrake@acm.org>
parents:
20247
diff
changeset
|
617 sys_getrefcount(PyObject *self, PyObject *arg) |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
618 { |
|
36866
9eb24f92a784
Change int to Py_ssize_t in several places.
Martin v. Löwis <martin@v.loewis.de>
parents:
36837
diff
changeset
|
619 return PyInt_FromSsize_t(arg->ob_refcnt); |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
620 } |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
621 |
|
24126
fdf80e04e4bb
Rearranged and added comments to object.h, to clarify many things
Tim Peters <tim.peters@gmail.com>
parents:
24071
diff
changeset
|
622 #ifdef Py_REF_DEBUG |
|
12965
04c89d77dfdb
Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows).
Mark Hammond <mhammond@skippinet.com.au>
parents:
12877
diff
changeset
|
623 static PyObject * |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
624 sys_gettotalrefcount(PyObject *self) |
|
12965
04c89d77dfdb
Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows).
Mark Hammond <mhammond@skippinet.com.au>
parents:
12877
diff
changeset
|
625 { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
626 return PyInt_FromSsize_t(_Py_GetRefTotal()); |
|
12965
04c89d77dfdb
Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows).
Mark Hammond <mhammond@skippinet.com.au>
parents:
12877
diff
changeset
|
627 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
628 #endif /* Py_REF_DEBUG */ |
|
12965
04c89d77dfdb
Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows).
Mark Hammond <mhammond@skippinet.com.au>
parents:
12877
diff
changeset
|
629 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
630 PyDoc_STRVAR(getrefcount_doc, |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
631 "getrefcount(object) -> integer\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
632 \n\ |
|
23947
37118b6e5f46
Fix the docstring for sys.getrefcount().
Fred Drake <fdrake@acm.org>
parents:
23746
diff
changeset
|
633 Return the reference count of object. The count returned is generally\n\ |
|
37118b6e5f46
Fix the docstring for sys.getrefcount().
Fred Drake <fdrake@acm.org>
parents:
23746
diff
changeset
|
634 one higher than you might expect, because it includes the (temporary)\n\ |
|
37118b6e5f46
Fix the docstring for sys.getrefcount().
Fred Drake <fdrake@acm.org>
parents:
23746
diff
changeset
|
635 reference as an argument to getrefcount()." |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
636 ); |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
637 |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
638 #ifdef COUNT_ALLOCS |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
639 static PyObject * |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
640 sys_getcounts(PyObject *self) |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
641 { |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
642 extern PyObject *get_counts(void); |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
643 |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
644 return get_counts(); |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
645 } |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
646 #endif |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
647 |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
648 PyDoc_STRVAR(getframe_doc, |
|
15487
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
649 "_getframe([depth]) -> frameobject\n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
650 \n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
651 Return a frame object from the call stack. If optional integer depth is\n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
652 given, return the frame object that many calls below the top of the stack.\n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
653 If that is deeper than the call stack, ValueError is raised. The default\n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
654 for depth is zero, returning the frame at the top of the call stack.\n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
655 \n\ |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
656 This function should be used for internal and specialized\n\ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
657 purposes only." |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
658 ); |
|
15487
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
659 |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
660 static PyObject * |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
661 sys_getframe(PyObject *self, PyObject *args) |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
662 { |
|
31797
846b3ee7e106
Changed random calls to PyThreadState_Get() to use the macro
Nicholas Bastin <nick.bastin@gmail.com>
parents:
31796
diff
changeset
|
663 PyFrameObject *f = PyThreadState_GET()->frame; |
|
15487
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
664 int depth = -1; |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
665 |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
666 if (!PyArg_ParseTuple(args, "|i:_getframe", &depth)) |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
667 return NULL; |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
668 |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
669 while (depth > 0 && f != NULL) { |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
670 f = f->f_back; |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
671 --depth; |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
672 } |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
673 if (f == NULL) { |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
674 PyErr_SetString(PyExc_ValueError, |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
675 "call stack is not deep enough"); |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
676 return NULL; |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
677 } |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
678 Py_INCREF(f); |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
679 return (PyObject*)f; |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
680 } |
|
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
681 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
682 PyDoc_STRVAR(current_frames_doc, |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
683 "_current_frames() -> dictionary\n\ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
684 \n\ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
685 Return a dictionary mapping each current thread T's thread id to T's\n\ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
686 current stack frame.\n\ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
687 \n\ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
688 This function should be used for specialized purposes only." |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
689 ); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
690 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
691 static PyObject * |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
692 sys_current_frames(PyObject *self, PyObject *noargs) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
693 { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
694 return _PyThread_CurrentFrames(); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
695 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
696 |
|
28556
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
697 PyDoc_STRVAR(call_tracing_doc, |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
698 "call_tracing(func, args) -> object\n\ |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
699 \n\ |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
700 Call func(*args), while tracing is enabled. The tracing state is\n\ |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
701 saved, and restored afterwards. This is intended to be called from\n\ |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
702 a debugger from a checkpoint, to recursively debug some other code." |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
703 ); |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
704 |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
705 static PyObject * |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
706 sys_call_tracing(PyObject *self, PyObject *args) |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
707 { |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
708 PyObject *func, *funcargs; |
|
38669
19fd6141940d
Partially merge trunk into p3yk. The removal of Mac/Tools is confusing svn
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
709 if (!PyArg_UnpackTuple(args, "call_tracing", 2, 2, &func, &funcargs)) |
|
28556
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
710 return NULL; |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
711 return _PyEval_CallTracing(func, funcargs); |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
712 } |
|
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
713 |
|
27712
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
714 PyDoc_STRVAR(callstats_doc, |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
715 "callstats() -> tuple of integers\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
716 \n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
717 Return a tuple of function call statistics, if CALL_PROFILE was defined\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
718 when Python was built. Otherwise, return None.\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
719 \n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
720 When enabled, this function returns detailed, implementation-specific\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
721 details about the number of function calls executed. The return value is\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
722 a 11-tuple where the entries in the tuple are counts of:\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
723 0. all function calls\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
724 1. calls to PyFunction_Type objects\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
725 2. PyFunction calls that do not create an argument tuple\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
726 3. PyFunction calls that do not create an argument tuple\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
727 and bypass PyEval_EvalCodeEx()\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
728 4. PyMethod calls\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
729 5. PyMethod calls on bound methods\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
730 6. PyType calls\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
731 7. PyCFunction calls\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
732 8. generator calls\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
733 9. All other calls\n\ |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
734 10. Number of stack pops performed by call_function()" |
|
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
735 ); |
|
15487
f0ca4c67957b
_getframe(): New sys module function for getting at the stack frame.
Barry Warsaw <barry@python.org>
parents:
14375
diff
changeset
|
736 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
737 #ifdef __cplusplus |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
738 extern "C" { |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
739 #endif |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
740 |
|
3585
4ed09a3c3201
TRACE_REFS -> Py_TRACE_REFS
Guido van Rossum <guido@python.org>
parents:
3490
diff
changeset
|
741 #ifdef Py_TRACE_REFS |
|
3609
0b0c4ed1936a
rename printrefs, getobjects to _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
3585
diff
changeset
|
742 /* Defined in objects.c because it uses static globals if that file */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
743 extern PyObject *_Py_GetObjects(PyObject *, PyObject *); |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
744 #endif |
|
3609
0b0c4ed1936a
rename printrefs, getobjects to _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
3585
diff
changeset
|
745 |
|
5047
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
746 #ifdef DYNAMIC_EXECUTION_PROFILE |
|
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
747 /* Defined in ceval.c because it uses static globals if that file */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
748 extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *); |
|
5047
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
749 #endif |
|
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
750 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
751 #ifdef __cplusplus |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
752 } |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
753 #endif |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
754 |
| 5372 | 755 static PyMethodDef sys_methods[] = { |
|
5047
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
756 /* Might as well keep this in alphabetic order */ |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
757 {"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS, |
|
27712
16856c9514e0
Small function call optimization and special build option for call stats.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27156
diff
changeset
|
758 callstats_doc}, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
759 {"_current_frames", sys_current_frames, METH_NOARGS, |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
760 current_frames_doc}, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
761 {"displayhook", sys_displayhook, METH_O, displayhook_doc}, |
|
28119
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
762 {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc}, |
|
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
763 {"exc_clear", sys_exc_clear, METH_NOARGS, exc_clear_doc}, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
764 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, |
|
22604
3f4b2f93e8b5
Change sys_exit to use METH_VARARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
22531
diff
changeset
|
765 {"exit", sys_exit, METH_VARARGS, exit_doc}, |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
766 #ifdef Py_USING_UNICODE |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
767 {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, |
|
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
768 METH_NOARGS, getdefaultencoding_doc}, |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
769 #endif |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
770 #ifdef HAVE_DLOPEN |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
771 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
772 getdlopenflags_doc}, |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
773 #endif |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
774 #ifdef COUNT_ALLOCS |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
775 {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS}, |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
776 #endif |
|
5047
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
777 #ifdef DYNAMIC_EXECUTION_PROFILE |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
778 {"getdxp", _Py_GetDXProfile, METH_VARARGS}, |
|
5047
7a9cac7cb910
Added optional interface for dynamic execution profile (to be gathered
Guido van Rossum <guido@python.org>
parents:
4904
diff
changeset
|
779 #endif |
|
28174
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
780 #ifdef Py_USING_UNICODE |
|
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
781 {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
782 METH_NOARGS, getfilesystemencoding_doc}, |
|
28174
3f90d21debe9
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
Martin v. Löwis <martin@v.loewis.de>
parents:
28119
diff
changeset
|
783 #endif |
|
3585
4ed09a3c3201
TRACE_REFS -> Py_TRACE_REFS
Guido van Rossum <guido@python.org>
parents:
3490
diff
changeset
|
784 #ifdef Py_TRACE_REFS |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
785 {"getobjects", _Py_GetObjects, METH_VARARGS}, |
|
24126
fdf80e04e4bb
Rearranged and added comments to object.h, to clarify many things
Tim Peters <tim.peters@gmail.com>
parents:
24071
diff
changeset
|
786 #endif |
|
fdf80e04e4bb
Rearranged and added comments to object.h, to clarify many things
Tim Peters <tim.peters@gmail.com>
parents:
24071
diff
changeset
|
787 #ifdef Py_REF_DEBUG |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
788 {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS}, |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
789 #endif |
|
20655
7344687bf2c0
Convert getrefcount() to METH_O, and sys_excepthook() to use
Fred Drake <fdrake@acm.org>
parents:
20247
diff
changeset
|
790 {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, getrefcount_doc}, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
791 {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
792 getrecursionlimit_doc}, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
793 {"_getframe", sys_getframe, METH_VARARGS, getframe_doc}, |
|
25666
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
794 #ifdef MS_WINDOWS |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
795 {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
796 getwindowsversion_doc}, |
|
4a825b902310
Add os.path.supports_unicode_filenames for all platforms,
Mark Hammond <mhammond@skippinet.com.au>
parents:
25108
diff
changeset
|
797 #endif /* MS_WINDOWS */ |
|
40484
8565e3fea9b6
Patch #1601678: move intern() to sys.intern().
Georg Brandl <georg@python.org>
parents:
40450
diff
changeset
|
798 {"intern", sys_intern, METH_VARARGS, intern_doc}, |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
799 #ifdef USE_MALLOPT |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
800 {"mdebug", sys_mdebug, METH_VARARGS}, |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
801 #endif |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
802 #ifdef Py_USING_UNICODE |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
803 {"setdefaultencoding", sys_setdefaultencoding, METH_VARARGS, |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
804 setdefaultencoding_doc}, |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
805 #endif |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
806 {"setcheckinterval", sys_setcheckinterval, METH_VARARGS, |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
807 setcheckinterval_doc}, |
|
29765
e9e5832d706f
New function sys.getcheckinterval(), to complement setcheckinterval().
Tim Peters <tim.peters@gmail.com>
parents:
29065
diff
changeset
|
808 {"getcheckinterval", sys_getcheckinterval, METH_NOARGS, |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
809 getcheckinterval_doc}, |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
810 #ifdef HAVE_DLOPEN |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
811 {"setdlopenflags", sys_setdlopenflags, METH_VARARGS, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
812 setdlopenflags_doc}, |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
813 #endif |
|
22119
0859e764509e
SF #506611, fix sys.setprofile(), sys.settrace() core dumps
Neal Norwitz <nnorwitz@gmail.com>
parents:
21833
diff
changeset
|
814 {"setprofile", sys_setprofile, METH_O, setprofile_doc}, |
|
19301
b9701538f827
Patch #427190: Implement and use METH_NOARGS and METH_O.
Martin v. Löwis <martin@v.loewis.de>
parents:
18805
diff
changeset
|
815 {"setrecursionlimit", sys_setrecursionlimit, METH_VARARGS, |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
816 setrecursionlimit_doc}, |
|
32301
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
817 #ifdef WITH_TSC |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
818 {"settscdump", sys_settscdump, METH_VARARGS, settscdump_doc}, |
|
41c59d80bbc5
Patch #510695: Add TSC profiling for the VM.
Martin v. Löwis <martin@v.loewis.de>
parents:
31797
diff
changeset
|
819 #endif |
|
22119
0859e764509e
SF #506611, fix sys.setprofile(), sys.settrace() core dumps
Neal Norwitz <nnorwitz@gmail.com>
parents:
21833
diff
changeset
|
820 {"settrace", sys_settrace, METH_O, settrace_doc}, |
|
28556
78395e5b4782
- New function sys.call_tracing() allows pdb to debug code
Guido van Rossum <guido@python.org>
parents:
28174
diff
changeset
|
821 {"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc}, |
| 86 | 822 {NULL, NULL} /* sentinel */ |
| 823 }; | |
| 824 | |
| 5372 | 825 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
826 list_builtin_module_names(void) |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
827 { |
| 5372 | 828 PyObject *list = PyList_New(0); |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
829 int i; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
830 if (list == NULL) |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
831 return NULL; |
|
6550
f406ec35bfca
Get rid of another reference to _PyImport_Inittab (now a static array)
Guido van Rossum <guido@python.org>
parents:
6352
diff
changeset
|
832 for (i = 0; PyImport_Inittab[i].name != NULL; i++) { |
|
5405
b7871ca930ad
Massive changes for separate thread state management.
Guido van Rossum <guido@python.org>
parents:
5377
diff
changeset
|
833 PyObject *name = PyString_FromString( |
|
6550
f406ec35bfca
Get rid of another reference to _PyImport_Inittab (now a static array)
Guido van Rossum <guido@python.org>
parents:
6352
diff
changeset
|
834 PyImport_Inittab[i].name); |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
835 if (name == NULL) |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
836 break; |
| 5372 | 837 PyList_Append(list, name); |
| 838 Py_DECREF(name); | |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
839 } |
| 5372 | 840 if (PyList_Sort(list) != 0) { |
| 841 Py_DECREF(list); | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
842 list = NULL; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
843 } |
|
4904
5dc20a9e0506
Make builtin_module_names a tuple instead of a list.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
844 if (list) { |
| 5372 | 845 PyObject *v = PyList_AsTuple(list); |
| 846 Py_DECREF(list); | |
|
4904
5dc20a9e0506
Make builtin_module_names a tuple instead of a list.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
847 list = v; |
|
5dc20a9e0506
Make builtin_module_names a tuple instead of a list.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
848 } |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
849 return list; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
850 } |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
851 |
|
15595
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
852 static PyObject *warnoptions = NULL; |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
853 |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
854 void |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
855 PySys_ResetWarnOptions(void) |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
856 { |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
857 if (warnoptions == NULL || !PyList_Check(warnoptions)) |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
858 return; |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
859 PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
860 } |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
861 |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
862 void |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
863 PySys_AddWarnOption(char *s) |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
864 { |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
865 PyObject *str; |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
866 |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
867 if (warnoptions == NULL || !PyList_Check(warnoptions)) { |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
868 Py_XDECREF(warnoptions); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
869 warnoptions = PyList_New(0); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
870 if (warnoptions == NULL) |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
871 return; |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
872 } |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
873 str = PyString_FromString(s); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
874 if (str != NULL) { |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
875 PyList_Append(warnoptions, str); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
876 Py_DECREF(str); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
877 } |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
878 } |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
879 |
|
8840
44baef8ab5c8
Gack. The module doc string is too long for VC++ 5.0.
Guido van Rossum <guido@python.org>
parents:
8566
diff
changeset
|
880 /* XXX This doc string is too long to be a single string literal in VC++ 5.0. |
|
44baef8ab5c8
Gack. The module doc string is too long for VC++ 5.0.
Guido van Rossum <guido@python.org>
parents:
8566
diff
changeset
|
881 Two literals concatenated works just fine. If you have a K&R compiler |
|
44baef8ab5c8
Gack. The module doc string is too long for VC++ 5.0.
Guido van Rossum <guido@python.org>
parents:
8566
diff
changeset
|
882 or other abomination that however *does* understand longer strings, |
|
44baef8ab5c8
Gack. The module doc string is too long for VC++ 5.0.
Guido van Rossum <guido@python.org>
parents:
8566
diff
changeset
|
883 get rid of the !!! comment in the middle and the quotes that surround it. */ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
884 PyDoc_VAR(sys_doc) = |
|
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
885 PyDoc_STR( |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
886 "This module provides access to some objects used or maintained by the\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
887 interpreter and to functions that interact strongly with the interpreter.\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
888 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
889 Dynamic objects:\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
890 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
891 argv -- command line arguments; argv[0] is the script pathname if known\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
892 path -- module search path; path[0] is the script directory, else ''\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
893 modules -- dictionary of loaded modules\n\ |
| 17164 | 894 \n\ |
| 895 displayhook -- called to show results in an interactive session\n\ | |
| 896 excepthook -- called to handle any uncaught exception other than SystemExit\n\ | |
| 897 To customize printing in an interactive session or to install a custom\n\ | |
| 898 top-level exception handler, assign other functions to replace these.\n\ | |
| 899 \n\ | |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
900 stdin -- standard input file object; used by raw_input() and input()\n\ |
|
40788
e9a6234b26af
* Remove PRINT_ITEM(_TO), PRINT_NEWLINE(_TO) opcodes.
Georg Brandl <georg@python.org>
parents:
40737
diff
changeset
|
901 stdout -- standard output file object; used by print()\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
902 stderr -- standard error object; used for error messages\n\ |
| 17164 | 903 By assigning other file objects (or objects that behave like files)\n\ |
| 904 to these, it is possible to redirect all of the interpreter's I/O.\n\ | |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
905 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
906 last_type -- type of last uncaught exception\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
907 last_value -- value of last uncaught exception\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
908 last_traceback -- traceback of last uncaught exception\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
909 These three are only available in an interactive session after a\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
910 traceback has been printed.\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
911 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
912 exc_type -- type of exception currently being handled\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
913 exc_value -- value of exception currently being handled\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
914 exc_traceback -- traceback of exception currently being handled\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
915 The function exc_info() should be used instead of these three,\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
916 because it is thread-safe.\n\ |
|
9885
030ee50bd8d1
Jim Ahlstrom patch: the module doc string is too long for 16-bit VC
Guido van Rossum <guido@python.org>
parents:
9746
diff
changeset
|
917 " |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
918 ) |
| 17164 | 919 /* concatenating string here */ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
920 PyDoc_STR( |
|
9885
030ee50bd8d1
Jim Ahlstrom patch: the module doc string is too long for 16-bit VC
Guido van Rossum <guido@python.org>
parents:
9746
diff
changeset
|
921 "\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
922 Static objects:\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
923 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
924 maxint -- the largest supported integer (the smallest is -maxint-1)\n\ |
|
18298
982163c4e9d2
Encode surrogates in UTF-8 even for a wide Py_UNICODE.
Martin v. Löwis <martin@v.loewis.de>
parents:
18136
diff
changeset
|
925 maxunicode -- the largest supported character\n\ |
|
21833
070d392042e3
Fix spelling mistakes. Bugfix candidates.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21712
diff
changeset
|
926 builtin_module_names -- tuple of module names built into this interpreter\n\ |
|
12394
60dd95c75999
Define version_info to be a tuple (major, minor, micro, level); level
Fred Drake <fdrake@acm.org>
parents:
12136
diff
changeset
|
927 version -- the version of this interpreter as a string\n\ |
|
60dd95c75999
Define version_info to be a tuple (major, minor, micro, level); level
Fred Drake <fdrake@acm.org>
parents:
12136
diff
changeset
|
928 version_info -- version information as a tuple\n\ |
|
60dd95c75999
Define version_info to be a tuple (major, minor, micro, level); level
Fred Drake <fdrake@acm.org>
parents:
12136
diff
changeset
|
929 hexversion -- version information encoded as a single integer\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
930 copyright -- copyright notice pertaining to this interpreter\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
931 platform -- platform identifier\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
932 executable -- pathname of this Python interpreter\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
933 prefix -- prefix used to find the Python library\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
934 exec_prefix -- prefix used to find the machine-specific Python library\n\ |
| 17164 | 935 " |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
936 ) |
| 17164 | 937 #ifdef MS_WINDOWS |
| 938 /* concatenating string here */ | |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
939 PyDoc_STR( |
| 17164 | 940 "dllhandle -- [Windows only] integer handle of the Python DLL\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
941 winver -- [Windows only] version number of the Python DLL\n\ |
| 17164 | 942 " |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
943 ) |
| 17164 | 944 #endif /* MS_WINDOWS */ |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
945 PyDoc_STR( |
| 17164 | 946 "__stdin__ -- the original stdin; don't touch!\n\ |
| 947 __stdout__ -- the original stdout; don't touch!\n\ | |
| 948 __stderr__ -- the original stderr; don't touch!\n\ | |
| 949 __displayhook__ -- the original displayhook; don't touch!\n\ | |
| 950 __excepthook__ -- the original excepthook; don't touch!\n\ | |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
951 \n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
952 Functions:\n\ |
|
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
953 \n\ |
|
15811
1a00d21910c8
Implementation of PEP-0217.
Moshe Zadka <moshez@math.huji.ac.il>
parents:
15595
diff
changeset
|
954 displayhook() -- print an object to the screen, and save it in __builtin__._\n\ |
| 17164 | 955 excepthook() -- print an exception and its traceback to sys.stderr\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
956 exc_info() -- return thread-safe information about the current exception\n\ |
|
28119
869695cba2cd
- New function sys.exc_clear() clears the current exception. This is
Guido van Rossum <guido@python.org>
parents:
27977
diff
changeset
|
957 exc_clear() -- clear the exception state for the current thread\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
958 exit() -- exit the interpreter by raising SystemExit\n\ |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
959 getdlopenflags() -- returns flags to be used for dlopen() calls\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
960 getrefcount() -- return the reference count for an object (plus one :-)\n\ |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
961 getrecursionlimit() -- return the max recursion depth for the interpreter\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
962 setcheckinterval() -- control how often the interpreter checks for events\n\ |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
18326
diff
changeset
|
963 setdlopenflags() -- set the flags to be used for dlopen() calls\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
964 setprofile() -- set the global profiling function\n\ |
|
14308
b8b3f76ffd51
add user-modifiable recursion_limit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
14295
diff
changeset
|
965 setrecursionlimit() -- set the max recursion depth for the interpreter\n\ |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
966 settrace() -- set the global debug tracing function\n\ |
|
13971
aa4202702252
The attempt to protect against MS_WIN16 compilers that do not support long
Fred Drake <fdrake@acm.org>
parents:
13968
diff
changeset
|
967 " |
|
23746
43ddcdcd3c71
Patch #505375: Make doc strings optional.
Martin v. Löwis <martin@v.loewis.de>
parents:
22604
diff
changeset
|
968 ) |
|
13971
aa4202702252
The attempt to protect against MS_WIN16 compilers that do not support long
Fred Drake <fdrake@acm.org>
parents:
13968
diff
changeset
|
969 /* end of sys_doc */ ; |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
970 |
|
34483
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
971 static int |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
972 _check_and_flush (FILE *stream) |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
973 { |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
974 int prev_fail = ferror (stream); |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
975 return fflush (stream) || prev_fail ? EOF : 0; |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
976 } |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
977 |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
978 /* Subversion branch and revision management */ |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
979 static const char _patchlevel_revision[] = PY_PATCHLEVEL_REVISION; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
980 static const char headurl[] = "$HeadURL$"; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
981 static int svn_initialized; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
982 static char patchlevel_revision[50]; /* Just the number */ |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
983 static char branch[50]; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
984 static char shortbranch[50]; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
985 static const char *svn_revision; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
986 |
|
36212
cee05980f1fd
svnversion_init(): Use standard layout for function defn.
Tim Peters <tim.peters@gmail.com>
parents:
36211
diff
changeset
|
987 static void |
|
cee05980f1fd
svnversion_init(): Use standard layout for function defn.
Tim Peters <tim.peters@gmail.com>
parents:
36211
diff
changeset
|
988 svnversion_init(void) |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
989 { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
990 const char *python, *br_start, *br_end, *br_end2, *svnversion; |
|
36521
30aef3ce2b26
Use Py_ssize_t to count the
Martin v. Löwis <martin@v.loewis.de>
parents:
36501
diff
changeset
|
991 Py_ssize_t len; |
|
30aef3ce2b26
Use Py_ssize_t to count the
Martin v. Löwis <martin@v.loewis.de>
parents:
36501
diff
changeset
|
992 int istag; |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
993 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
994 if (svn_initialized) |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
995 return; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
996 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
997 python = strstr(headurl, "/python/"); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
998 if (!python) |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
999 Py_FatalError("subversion keywords missing"); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1000 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1001 br_start = python + 8; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1002 br_end = strchr(br_start, '/'); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1003 assert(br_end); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1004 |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
1005 /* Works even for trunk, |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1006 as we are in trunk/Python/sysmodule.c */ |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1007 br_end2 = strchr(br_end+1, '/'); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1008 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1009 istag = strncmp(br_start, "tags", 4) == 0; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1010 if (strncmp(br_start, "trunk", 5) == 0) { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1011 strcpy(branch, "trunk"); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1012 strcpy(shortbranch, "trunk"); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1013 |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
1014 } |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1015 else if (istag || strncmp(br_start, "branches", 8) == 0) { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1016 len = br_end2 - br_start; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1017 strncpy(branch, br_start, len); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1018 branch[len] = '\0'; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1019 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1020 len = br_end2 - (br_end + 1); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1021 strncpy(shortbranch, br_end + 1, len); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1022 shortbranch[len] = '\0'; |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
1023 } |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1024 else { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1025 Py_FatalError("bad HeadURL"); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1026 return; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1027 } |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1028 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1029 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1030 svnversion = _Py_svnversion(); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1031 if (strcmp(svnversion, "exported") != 0) |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1032 svn_revision = svnversion; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1033 else if (istag) { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1034 len = strlen(_patchlevel_revision); |
|
41554
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41253
diff
changeset
|
1035 assert(len >= 13); |
|
06145fbc7ab9
Merged revisions 53952-54987 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41253
diff
changeset
|
1036 assert(len < (sizeof(patchlevel_revision) + 13)); |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1037 strncpy(patchlevel_revision, _patchlevel_revision + 11, |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1038 len - 13); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1039 patchlevel_revision[len - 13] = '\0'; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1040 svn_revision = patchlevel_revision; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1041 } |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1042 else |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1043 svn_revision = ""; |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
1044 |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1045 svn_initialized = 1; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1046 } |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1047 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1048 /* Return svnversion output if available. |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1049 Else return Revision of patchlevel.h if on branch. |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1050 Else return empty string */ |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1051 const char* |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1052 Py_SubversionRevision() |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1053 { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1054 svnversion_init(); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1055 return svn_revision; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1056 } |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1057 |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1058 const char* |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1059 Py_SubversionShortBranch() |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1060 { |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1061 svnversion_init(); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1062 return shortbranch; |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1063 } |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1064 |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1065 PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
1066 _PySys_Init(void) |
| 6 | 1067 { |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1068 PyObject *m, *v, *sysdict; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1069 PyObject *sysin, *sysout, *syserr; |
|
12398
2392d10e21f1
Simplify creation of the version_info value for clarity, per
Fred Drake <fdrake@acm.org>
parents:
12396
diff
changeset
|
1070 char *s; |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1071 #ifdef MS_WINDOWS |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
38669
diff
changeset
|
1072 char buf[128]; |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1073 #endif |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1074 |
|
8566
6e8b0e754a7f
Added doc strings. Maybe the doc string for the module itself is a bit
Guido van Rossum <guido@python.org>
parents:
8314
diff
changeset
|
1075 m = Py_InitModule3("sys", sys_methods, sys_doc); |
|
36324
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36212
diff
changeset
|
1076 if (m == NULL) |
|
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36212
diff
changeset
|
1077 return NULL; |
| 5372 | 1078 sysdict = PyModule_GetDict(m); |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1079 |
|
35673
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1080 { |
|
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1081 /* XXX: does this work on Win/Win64? (see posix_fstat) */ |
|
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1082 struct stat sb; |
|
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1083 if (fstat(fileno(stdin), &sb) == 0 && |
|
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1084 S_ISDIR(sb.st_mode)) { |
|
36910
91a9e2e31e93
Try to be a bit more consistent on all platforms:
Neal Norwitz <nnorwitz@gmail.com>
parents:
36866
diff
changeset
|
1085 /* There's nothing more we can do. */ |
|
91a9e2e31e93
Try to be a bit more consistent on all platforms:
Neal Norwitz <nnorwitz@gmail.com>
parents:
36866
diff
changeset
|
1086 /* Py_FatalError() will core dump, so just exit. */ |
|
91a9e2e31e93
Try to be a bit more consistent on all platforms:
Neal Norwitz <nnorwitz@gmail.com>
parents:
36866
diff
changeset
|
1087 PySys_WriteStderr("Python error: <stdin> is a directory, cannot continue\n"); |
|
91a9e2e31e93
Try to be a bit more consistent on all platforms:
Neal Norwitz <nnorwitz@gmail.com>
parents:
36866
diff
changeset
|
1088 exit(EXIT_FAILURE); |
|
35673
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1089 } |
|
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1090 } |
|
612a12178e47
SF bug #887946, segfault if redirecting directory
Neal Norwitz <nnorwitz@gmail.com>
parents:
35572
diff
changeset
|
1091 |
|
34511
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1092 /* Closing the standard FILE* if sys.std* goes aways causes problems |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1093 * for embedded Python usages. Closing them when somebody explicitly |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1094 * invokes .close() might be possible, but the FAQ promises they get |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1095 * never closed. However, we still need to get write errors when |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1096 * writing fails (e.g. because stdout is redirected), so we flush the |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1097 * streams and check for errors before the file objects are deleted. |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1098 * On OS X, fflush()ing stdin causes an error, so we exempt stdin |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1099 * from that procedure. |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1100 */ |
|
91038801eb45
Partially revert #1074011; don't try to fflush stdin.
Martin v. Löwis <martin@v.loewis.de>
parents:
34483
diff
changeset
|
1101 sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL); |
|
34483
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
1102 sysout = PyFile_FromFile(stdout, "<stdout>", "w", _check_and_flush); |
|
4a1fefdfc793
Flush std{in,out,err} before closing it. Fixes #1074011.
Martin v. Löwis <martin@v.loewis.de>
parents:
33104
diff
changeset
|
1103 syserr = PyFile_FromFile(stderr, "<stderr>", "w", _check_and_flush); |
| 5372 | 1104 if (PyErr_Occurred()) |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1105 return NULL; |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1106 #ifdef MS_WINDOWS |
|
40737
6ebad2a6b990
Merged revisions 53451-53537 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40484
diff
changeset
|
1107 if(isatty(_fileno(stdin)) && PyFile_Check(sysin)) { |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1108 sprintf(buf, "cp%d", GetConsoleCP()); |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1109 if (!PyFile_SetEncoding(sysin, buf)) |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1110 return NULL; |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1111 } |
|
40737
6ebad2a6b990
Merged revisions 53451-53537 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40484
diff
changeset
|
1112 if(isatty(_fileno(stdout)) && PyFile_Check(sysout)) { |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1113 sprintf(buf, "cp%d", GetConsoleOutputCP()); |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1114 if (!PyFile_SetEncoding(sysout, buf)) |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1115 return NULL; |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1116 } |
|
40737
6ebad2a6b990
Merged revisions 53451-53537 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40484
diff
changeset
|
1117 if(isatty(_fileno(stderr)) && PyFile_Check(syserr)) { |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
1118 sprintf(buf, "cp%d", GetConsoleOutputCP()); |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
1119 if (!PyFile_SetEncoding(syserr, buf)) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
1120 return NULL; |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
1121 } |
|
29065
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1122 #endif |
|
bf1634b023d5
Patch #612627: Add encoding attribute to file objects, and determine
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
1123 |
| 5372 | 1124 PyDict_SetItemString(sysdict, "stdin", sysin); |
| 1125 PyDict_SetItemString(sysdict, "stdout", sysout); | |
| 1126 PyDict_SetItemString(sysdict, "stderr", syserr); | |
|
7402
c7454ca7d3ac
Make backup copies of stdin, stdout, stderr as __stdin__, __stdout__,
Guido van Rossum <guido@python.org>
parents:
6550
diff
changeset
|
1127 /* Make backup copies for cleanup */ |
|
c7454ca7d3ac
Make backup copies of stdin, stdout, stderr as __stdin__, __stdout__,
Guido van Rossum <guido@python.org>
parents:
6550
diff
changeset
|
1128 PyDict_SetItemString(sysdict, "__stdin__", sysin); |
|
c7454ca7d3ac
Make backup copies of stdin, stdout, stderr as __stdin__, __stdout__,
Guido van Rossum <guido@python.org>
parents:
6550
diff
changeset
|
1129 PyDict_SetItemString(sysdict, "__stdout__", sysout); |
|
c7454ca7d3ac
Make backup copies of stdin, stdout, stderr as __stdin__, __stdout__,
Guido van Rossum <guido@python.org>
parents:
6550
diff
changeset
|
1130 PyDict_SetItemString(sysdict, "__stderr__", syserr); |
| 17164 | 1131 PyDict_SetItemString(sysdict, "__displayhook__", |
| 1132 PyDict_GetItemString(sysdict, "displayhook")); | |
| 1133 PyDict_SetItemString(sysdict, "__excepthook__", | |
| 1134 PyDict_GetItemString(sysdict, "excepthook")); | |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1135 Py_XDECREF(sysin); |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1136 Py_XDECREF(sysout); |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1137 Py_XDECREF(syserr); |
| 5372 | 1138 PyDict_SetItemString(sysdict, "version", |
| 1139 v = PyString_FromString(Py_GetVersion())); | |
|
9964
d44cb87e500d
_PySys_Init(): Nailed small memory leak. The stringobject created for
Barry Warsaw <barry@python.org>
parents:
9885
diff
changeset
|
1140 Py_XDECREF(v); |
|
9746
9342c60eaac0
Add sys.hexversion, which is an integer encoding the version in hexadecimal.
Guido van Rossum <guido@python.org>
parents:
9328
diff
changeset
|
1141 PyDict_SetItemString(sysdict, "hexversion", |
|
9342c60eaac0
Add sys.hexversion, which is an integer encoding the version in hexadecimal.
Guido van Rossum <guido@python.org>
parents:
9328
diff
changeset
|
1142 v = PyInt_FromLong(PY_VERSION_HEX)); |
| 5372 | 1143 Py_XDECREF(v); |
|
36207
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1144 svnversion_init(); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1145 v = Py_BuildValue("(ssz)", "CPython", branch, svn_revision); |
|
825a041813fb
Drop sys.build_number. Add sys.subversion.
Martin v. Löwis <martin@v.loewis.de>
parents:
36070
diff
changeset
|
1146 PyDict_SetItemString(sysdict, "subversion", v); |
|
36070
9697eeeaf246
Expose Subversion revision number (calculated via "svnversion .") to Python.
Barry Warsaw <barry@python.org>
parents:
35742
diff
changeset
|
1147 Py_XDECREF(v); |
|
12396
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1148 /* |
|
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1149 * These release level checks are mutually exclusive and cover |
|
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1150 * the field, so don't get too fancy with the pre-processor! |
|
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1151 */ |
|
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1152 #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA |
|
12398
2392d10e21f1
Simplify creation of the version_info value for clarity, per
Fred Drake <fdrake@acm.org>
parents:
12396
diff
changeset
|
1153 s = "alpha"; |
|
14295
e5253b692e9f
_PySys_Init(): When setting up sys.version_info, use #if/#elif.../#endif
Fred Drake <fdrake@acm.org>
parents:
14017
diff
changeset
|
1154 #elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_BETA |
|
12398
2392d10e21f1
Simplify creation of the version_info value for clarity, per
Fred Drake <fdrake@acm.org>
parents:
12396
diff
changeset
|
1155 s = "beta"; |
|
14295
e5253b692e9f
_PySys_Init(): When setting up sys.version_info, use #if/#elif.../#endif
Fred Drake <fdrake@acm.org>
parents:
14017
diff
changeset
|
1156 #elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_GAMMA |
|
12398
2392d10e21f1
Simplify creation of the version_info value for clarity, per
Fred Drake <fdrake@acm.org>
parents:
12396
diff
changeset
|
1157 s = "candidate"; |
|
14295
e5253b692e9f
_PySys_Init(): When setting up sys.version_info, use #if/#elif.../#endif
Fred Drake <fdrake@acm.org>
parents:
14017
diff
changeset
|
1158 #elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL |
|
12398
2392d10e21f1
Simplify creation of the version_info value for clarity, per
Fred Drake <fdrake@acm.org>
parents:
12396
diff
changeset
|
1159 s = "final"; |
|
12396
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1160 #endif |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1161 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1162 #define SET_SYS_FROM_STRING(key, value) \ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1163 v = value; \ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1164 if (v != NULL) \ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1165 PyDict_SetItemString(sysdict, key, v); \ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1166 Py_XDECREF(v) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1167 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1168 SET_SYS_FROM_STRING("version_info", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1169 Py_BuildValue("iiisi", PY_MAJOR_VERSION, |
|
12394
60dd95c75999
Define version_info to be a tuple (major, minor, micro, level); level
Fred Drake <fdrake@acm.org>
parents:
12136
diff
changeset
|
1170 PY_MINOR_VERSION, |
|
12398
2392d10e21f1
Simplify creation of the version_info value for clarity, per
Fred Drake <fdrake@acm.org>
parents:
12396
diff
changeset
|
1171 PY_MICRO_VERSION, s, |
|
12396
f82b2577fa0c
Capitulate, changing version_info to a 5-tuple:
Fred Drake <fdrake@acm.org>
parents:
12394
diff
changeset
|
1172 PY_RELEASE_SERIAL)); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1173 SET_SYS_FROM_STRING("api_version", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1174 PyInt_FromLong(PYTHON_API_VERSION)); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1175 SET_SYS_FROM_STRING("copyright", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1176 PyString_FromString(Py_GetCopyright())); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1177 SET_SYS_FROM_STRING("platform", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1178 PyString_FromString(Py_GetPlatform())); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1179 SET_SYS_FROM_STRING("executable", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1180 PyString_FromString(Py_GetProgramFullPath())); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1181 SET_SYS_FROM_STRING("prefix", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1182 PyString_FromString(Py_GetPrefix())); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1183 SET_SYS_FROM_STRING("exec_prefix", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1184 PyString_FromString(Py_GetExecPrefix())); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1185 SET_SYS_FROM_STRING("maxint", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1186 PyInt_FromLong(PyInt_GetMax())); |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
1187 #ifdef Py_USING_UNICODE |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1188 SET_SYS_FROM_STRING("maxunicode", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1189 PyInt_FromLong(PyUnicode_GetMax())); |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
19301
diff
changeset
|
1190 #endif |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1191 SET_SYS_FROM_STRING("builtin_module_names", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1192 list_builtin_module_names()); |
|
13968
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1193 { |
|
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1194 /* Assumes that longs are at least 2 bytes long. |
|
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1195 Should be safe! */ |
|
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1196 unsigned long number = 1; |
|
13977
eb9a36163a9e
Guido pointed out that all names in the sys module have no underscore,
Fred Drake <fdrake@acm.org>
parents:
13971
diff
changeset
|
1197 char *value; |
|
13968
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1198 |
|
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1199 s = (char *) &number; |
|
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1200 if (s[0] == 0) |
|
13977
eb9a36163a9e
Guido pointed out that all names in the sys module have no underscore,
Fred Drake <fdrake@acm.org>
parents:
13971
diff
changeset
|
1201 value = "big"; |
|
13968
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1202 else |
|
13977
eb9a36163a9e
Guido pointed out that all names in the sys module have no underscore,
Fred Drake <fdrake@acm.org>
parents:
13971
diff
changeset
|
1203 value = "little"; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1204 SET_SYS_FROM_STRING("byteorder", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1205 PyString_FromString(value)); |
|
13968
841cf9012ac3
Add a byte_order value to the sys module. The value is "big" for
Fred Drake <fdrake@acm.org>
parents:
13694
diff
changeset
|
1206 } |
|
4126
c80c515999b9
Use MS_DLL_ID as sys.winver
Guido van Rossum <guido@python.org>
parents:
3877
diff
changeset
|
1207 #ifdef MS_COREDLL |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1208 SET_SYS_FROM_STRING("dllhandle", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1209 PyLong_FromVoidPtr(PyWin_DLLhModule)); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1210 SET_SYS_FROM_STRING("winver", |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1211 PyString_FromString(PyWin_DLLVersionString)); |
|
3490
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
1212 #endif |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38673
diff
changeset
|
1213 #undef SET_SYS_FROM_STRING |
|
15595
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1214 if (warnoptions == NULL) { |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1215 warnoptions = PyList_New(0); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1216 } |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1217 else { |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1218 Py_INCREF(warnoptions); |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1219 } |
|
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1220 if (warnoptions != NULL) { |
|
15846
d41f9b0a40ca
Neil discovered a bad DECREF on warnoptions, that caused repeated
Guido van Rossum <guido@python.org>
parents:
15812
diff
changeset
|
1221 PyDict_SetItemString(sysdict, "warnoptions", warnoptions); |
|
15595
0f42f6669e80
Add definitions for PySys_ResetWarnOptions() and
Guido van Rossum <guido@python.org>
parents:
15487
diff
changeset
|
1222 } |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
1223 |
| 5372 | 1224 if (PyErr_Occurred()) |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1225 return NULL; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5863
diff
changeset
|
1226 return m; |
| 86 | 1227 } |
| 1228 | |
| 5372 | 1229 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
1230 makepathobject(char *path, int delim) |
| 86 | 1231 { |
| 1232 int i, n; | |
| 1233 char *p; | |
| 5372 | 1234 PyObject *v, *w; |
|
36211
6d743e5baf14
Trimmed trailing whitespace.
Tim Peters <tim.peters@gmail.com>
parents:
36207
diff
changeset
|
1235 |
| 86 | 1236 n = 1; |
| 1237 p = path; | |
| 1238 while ((p = strchr(p, delim)) != NULL) { | |
| 1239 n++; | |
| 1240 p++; | |
| 1241 } | |
| 5372 | 1242 v = PyList_New(n); |
| 86 | 1243 if (v == NULL) |
| 1244 return NULL; | |
| 1245 for (i = 0; ; i++) { | |
| 1246 p = strchr(path, delim); | |
| 1247 if (p == NULL) | |
| 1248 p = strchr(path, '\0'); /* End of string */ | |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39442
diff
changeset
|
1249 w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path)); |
| 86 | 1250 if (w == NULL) { |
| 5372 | 1251 Py_DECREF(v); |
| 86 | 1252 return NULL; |
| 1253 } | |
| 5372 | 1254 PyList_SetItem(v, i, w); |
| 86 | 1255 if (*p == '\0') |
| 1256 break; | |
| 1257 path = p+1; | |
| 1258 } | |
| 1259 return v; | |
| 1260 } | |
| 1261 | |
| 1262 void | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
1263 PySys_SetPath(char *path) |
| 86 | 1264 { |
| 5372 | 1265 PyObject *v; |
| 86 | 1266 if ((v = makepathobject(path, DELIM)) == NULL) |
| 5372 | 1267 Py_FatalError("can't create sys.path"); |
| 1268 if (PySys_SetObject("path", v) != 0) | |
| 1269 Py_FatalError("can't assign sys.path"); | |
| 1270 Py_DECREF(v); | |
|
83
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
1271 } |
|
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
1272 |
| 5372 | 1273 static PyObject * |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
1274 makeargvobject(int argc, char **argv) |
|
83
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
1275 { |
| 5372 | 1276 PyObject *av; |
|
596
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
1277 if (argc <= 0 || argv == NULL) { |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
1278 /* Ensure at least one (empty) argument is seen */ |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
1279 static char *empty_argv[1] = {""}; |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
1280 argv = empty_argv; |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
1281 argc = 1; |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
1282 } |
| 5372 | 1283 av = PyList_New(argc); |
| 86 | 1284 if (av != NULL) { |
| 1285 int i; | |
| 1286 for (i = 0; i < argc; i++) { | |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1287 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1288 PyObject *v; |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1289 |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1290 /* argv[0] is the script pathname if known */ |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1291 if (i == 0) { |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1292 char* fn = decc$translate_vms(argv[0]); |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1293 if ((fn == (char *)0) || fn == (char *)-1) |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1294 v = PyString_FromString(argv[0]); |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1295 else |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1296 v = PyString_FromString( |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1297 decc$translate_vms(argv[0])); |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1298 } else |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1299 v = PyString_FromString(argv[i]); |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1300 #else |
| 5372 | 1301 PyObject *v = PyString_FromString(argv[i]); |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
28556
diff
changeset
|
1302 #endif |
| 86 | 1303 if (v == NULL) { |
| 5372 | 1304 Py_DECREF(av); |
| 86 | 1305 av = NULL; |
| 1306 break; | |
| 1307 } | |
| 5372 | 1308 PyList_SetItem(av, i, v); |
|
83
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
1309 } |
|
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
1310 } |
| 86 | 1311 return av; |
| 6 | 1312 } |
| 1313 | |
| 1314 void | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
1315 PySys_SetArgv(int argc, char **argv) |
| 6 | 1316 { |
|
27977
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1317 #if defined(HAVE_REALPATH) |
|
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1318 char fullpath[MAXPATHLEN]; |
|
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1319 #elif defined(MS_WINDOWS) |
|
27156
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1320 char fullpath[MAX_PATH]; |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1321 #endif |
| 5372 | 1322 PyObject *av = makeargvobject(argc, argv); |
| 1323 PyObject *path = PySys_GetObject("path"); | |
| 86 | 1324 if (av == NULL) |
| 5372 | 1325 Py_FatalError("no mem for sys.argv"); |
| 1326 if (PySys_SetObject("argv", av) != 0) | |
| 1327 Py_FatalError("can't assign sys.argv"); | |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
1328 if (path != NULL) { |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1329 char *argv0 = argv[0]; |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
1330 char *p = NULL; |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
36324
diff
changeset
|
1331 Py_ssize_t n = 0; |
| 5372 | 1332 PyObject *a; |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1333 #ifdef HAVE_READLINK |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1334 char link[MAXPATHLEN+1]; |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1335 char argv0copy[2*MAXPATHLEN+1]; |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1336 int nr = 0; |
|
35572
1b25fe8834ae
patch [ 1119423 ] python -c readlink()s and stat()s '-c'
Georg Brandl <georg@python.org>
parents:
34511
diff
changeset
|
1337 if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0) |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1338 nr = readlink(argv0, link, MAXPATHLEN); |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1339 if (nr > 0) { |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1340 /* It's a symlink */ |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1341 link[nr] = '\0'; |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1342 if (link[0] == SEP) |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1343 argv0 = link; /* Link to absolute path */ |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1344 else if (strchr(link, SEP) == NULL) |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1345 ; /* Link without path */ |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1346 else { |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1347 /* Must join(dirname(argv0), link) */ |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1348 char *q = strrchr(argv0, SEP); |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1349 if (q == NULL) |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1350 argv0 = link; /* argv0 without path */ |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1351 else { |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1352 /* Must make a copy */ |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1353 strcpy(argv0copy, argv0); |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1354 q = strrchr(argv0copy, SEP); |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1355 strcpy(q+1, link); |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1356 argv0 = argv0copy; |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1357 } |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1358 } |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1359 } |
|
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1360 #endif /* HAVE_READLINK */ |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1361 #if SEP == '\\' /* Special case for MS filename syntax */ |
|
35572
1b25fe8834ae
patch [ 1119423 ] python -c readlink()s and stat()s '-c'
Georg Brandl <georg@python.org>
parents:
34511
diff
changeset
|
1362 if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0) { |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1363 char *q; |
|
27156
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1364 #ifdef MS_WINDOWS |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1365 char *ptemp; |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1366 if (GetFullPathName(argv0, |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1367 sizeof(fullpath), |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1368 fullpath, |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1369 &ptemp)) { |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1370 argv0 = fullpath; |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1371 } |
|
585a6460f577
Patch #664376: sys.path[0] should contain absolute pathname.
Thomas Heller <theller@ctypes.org>
parents:
25666
diff
changeset
|
1372 #endif |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1373 p = strrchr(argv0, SEP); |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1374 /* Test for alternate separator */ |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1375 q = strrchr(p ? p : argv0, '/'); |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1376 if (q != NULL) |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1377 p = q; |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1378 if (p != NULL) { |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1379 n = p + 1 - argv0; |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1380 if (n > 1 && p[-1] != ':') |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1381 n--; /* Drop trailing separator */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1382 } |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1383 } |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1384 #else /* All other filename syntaxes */ |
|
35572
1b25fe8834ae
patch [ 1119423 ] python -c readlink()s and stat()s '-c'
Georg Brandl <georg@python.org>
parents:
34511
diff
changeset
|
1385 if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0) { |
|
27977
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1386 #if defined(HAVE_REALPATH) |
|
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1387 if (realpath(argv0, fullpath)) { |
|
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1388 argv0 = fullpath; |
|
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1389 } |
|
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1390 #endif |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1391 p = strrchr(argv0, SEP); |
|
27977
0fe321e78ad3
- sys.path[0] (the directory from which the script is loaded) is now
Guido van Rossum <guido@python.org>
parents:
27712
diff
changeset
|
1392 } |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1393 if (p != NULL) { |
|
17396
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17164
diff
changeset
|
1394 #ifndef RISCOS |
|
5340
db673e98f28d
Expand one level of symbolic link in sys.argv[0] before inserting its
Guido van Rossum <guido@python.org>
parents:
5047
diff
changeset
|
1395 n = p + 1 - argv0; |
|
17396
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17164
diff
changeset
|
1396 #else /* don't include trailing separator */ |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17164
diff
changeset
|
1397 n = p - argv0; |
|
beb9d2b02846
Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger
Guido van Rossum <guido@python.org>
parents:
17164
diff
changeset
|
1398 #endif /* RISCOS */ |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1399 #if SEP == '/' /* Special case for Unix filename syntax */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1400 if (n > 1) |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1401 n--; /* Drop trailing separator */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1402 #endif /* Unix */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1403 } |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
1404 #endif /* All others */ |
| 5372 | 1405 a = PyString_FromStringAndSize(argv0, n); |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
1406 if (a == NULL) |
| 5372 | 1407 Py_FatalError("no mem for sys.path insertion"); |
| 1408 if (PyList_Insert(path, 0, a) < 0) | |
| 1409 Py_FatalError("sys.path.insert(0) failed"); | |
| 1410 Py_DECREF(a); | |
|
3806
93868c7a15c9
As a side effect of calling PySys_SetArgv (setpythonargv), the
Guido van Rossum <guido@python.org>
parents:
3738
diff
changeset
|
1411 } |
| 5372 | 1412 Py_DECREF(av); |
| 6 | 1413 } |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1414 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1415 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1416 /* APIs to write to sys.stdout or sys.stderr using a printf-like interface. |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1417 Adapted from code submitted by Just van Rossum. |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1418 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1419 PySys_WriteStdout(format, ...) |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1420 PySys_WriteStderr(format, ...) |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1421 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1422 The first function writes to sys.stdout; the second to sys.stderr. When |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1423 there is a problem, they write to the real (C level) stdout or stderr; |
|
9328
81574e4646b4
Patches for mywrite() by Marc Lemburg: save/restore the error state
Guido van Rossum <guido@python.org>
parents:
8840
diff
changeset
|
1424 no exceptions are raised. |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1425 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1426 Both take a printf-style format string as their first argument followed |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1427 by a variable length argument list determined by the format string. |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1428 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1429 *** WARNING *** |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1430 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1431 The format should limit the total size of the formatted output string to |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1432 1000 bytes. In particular, this means that no unrestricted "%s" formats |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1433 should occur; these should be limited using "%.<N>s where <N> is a |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1434 decimal number calculated so that <N> plus the maximum size of other |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1435 formatted text does not exceed 1000 bytes. Also watch out for "%f", |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1436 which can print hundreds of digits for very large numbers. |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1437 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1438 */ |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1439 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1440 static void |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13447
diff
changeset
|
1441 mywrite(char *name, FILE *fp, const char *format, va_list va) |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1442 { |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1443 PyObject *file; |
|
9328
81574e4646b4
Patches for mywrite() by Marc Lemburg: save/restore the error state
Guido van Rossum <guido@python.org>
parents:
8840
diff
changeset
|
1444 PyObject *error_type, *error_value, *error_traceback; |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1445 |
|
9328
81574e4646b4
Patches for mywrite() by Marc Lemburg: save/restore the error state
Guido van Rossum <guido@python.org>
parents:
8840
diff
changeset
|
1446 PyErr_Fetch(&error_type, &error_value, &error_traceback); |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1447 file = PySys_GetObject(name); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1448 if (file == NULL || PyFile_AsFile(file) == fp) |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1449 vfprintf(fp, format, va); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1450 else { |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1451 char buffer[1001]; |
|
21127
dd28a4ecb37f
mywrite(): The test for trouble in PyOS_vsnprintf was wrong on both
Tim Peters <tim.peters@gmail.com>
parents:
21091
diff
changeset
|
1452 const int written = PyOS_vsnprintf(buffer, sizeof(buffer), |
|
dd28a4ecb37f
mywrite(): The test for trouble in PyOS_vsnprintf was wrong on both
Tim Peters <tim.peters@gmail.com>
parents:
21091
diff
changeset
|
1453 format, va); |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1454 if (PyFile_WriteString(buffer, file) != 0) { |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1455 PyErr_Clear(); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1456 fputs(buffer, fp); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1457 } |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
37042
diff
changeset
|
1458 if (written < 0 || (size_t)written >= sizeof(buffer)) { |
|
21091
47f6533674fd
Use PyOS_vsnprintf() and check its return value.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20943
diff
changeset
|
1459 const char *truncated = "... truncated"; |
|
47f6533674fd
Use PyOS_vsnprintf() and check its return value.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20943
diff
changeset
|
1460 if (PyFile_WriteString(truncated, file) != 0) { |
|
47f6533674fd
Use PyOS_vsnprintf() and check its return value.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20943
diff
changeset
|
1461 PyErr_Clear(); |
|
47f6533674fd
Use PyOS_vsnprintf() and check its return value.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20943
diff
changeset
|
1462 fputs(truncated, fp); |
|
47f6533674fd
Use PyOS_vsnprintf() and check its return value.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20943
diff
changeset
|
1463 } |
|
47f6533674fd
Use PyOS_vsnprintf() and check its return value.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20943
diff
changeset
|
1464 } |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1465 } |
|
9328
81574e4646b4
Patches for mywrite() by Marc Lemburg: save/restore the error state
Guido van Rossum <guido@python.org>
parents:
8840
diff
changeset
|
1466 PyErr_Restore(error_type, error_value, error_traceback); |
|
8314
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1467 } |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1468 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1469 void |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1470 PySys_WriteStdout(const char *format, ...) |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1471 { |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1472 va_list va; |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1473 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1474 va_start(va, format); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1475 mywrite("stdout", stdout, format, va); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1476 va_end(va); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1477 } |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1478 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1479 void |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1480 PySys_WriteStderr(const char *format, ...) |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1481 { |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1482 va_list va; |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1483 |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1484 va_start(va, format); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1485 mywrite("stderr", stderr, format, va); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1486 va_end(va); |
|
f94d5ae642a9
New APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Guido van Rossum <guido@python.org>
parents:
7402
diff
changeset
|
1487 } |
