summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Issue #28350: String constants with null character no longer interned.Serhiy Storchaka2016-10-041-8/+8
|\
| * Issue #28350: String constants with null character no longer interned.Serhiy Storchaka2016-10-041-8/+8
| |
* | Issue #27942: String constants now interned recursively in tuples and ↵Serhiy Storchaka2016-09-301-7/+45
|\ \ | |/ | | | | frozensets.
| * Issue #27942: String constants now interned recursively in tuples and ↵Serhiy Storchaka2016-09-301-7/+45
| | | | | | | | frozensets.
| * Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Martin Panter2016-09-071-1/+1
| |
* | Make PyCodeObject.co_extra even more private to force users through the ↵Brett Cannon2016-09-071-23/+31
| | | | | | | | proper API.
* | Change error return value to be more consistent with the rest of PythonBrett Cannon2016-09-071-5/+5
| |
* | use a the bool type for a boolean variableBenjamin Peterson2016-09-071-2/+4
| |
* | Add the co_extra field and accompanying APIs to code objects.Brett Cannon2016-09-071-0/+91
| | | | | | | | This completes PEP 523.
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-1/+1
| |
* | Issue #15984: Merge PyUnicode doc from 3.5Martin Panter2016-04-151-1/+1
|\ \ | |/
| * Correct “an” → “a” with “Unicode”, “user”, “UTF”, etcMartin Panter2016-04-151-1/+1
| | | | | | | | This affects documentation, code comments, and a debugging messages.
| * code_richcompare() now uses the constants typesVictor Stinner2016-01-221-1/+138
| | | | | | | | | | | | | | | | | | Issue #25843: When compiling code, don't merge constants if they are equal but have a different types. For example, "f1, f2 = lambda: 1, lambda: 1.0" is now correctly compiled to two different functions: f1() returns 1 (int) and f2() returns 1.0 (int), even if 1 and 1.0 are equal. Add a new _PyCode_ConstantKey() private function.
* | code_richcompare() now uses the constants typesVictor Stinner2016-01-221-1/+138
| | | | | | | | | | | | | | | | | | Issue #25843: When compiling code, don't merge constants if they are equal but have a different types. For example, "f1, f2 = lambda: 1, lambda: 1.0" is now correctly compiled to two different functions: f1() returns 1 (int) and f2() returns 1.0 (int), even if 1 and 1.0 are equal. Add a new _PyCode_ConstantKey() private function.
* | co_lnotab supports negative line number deltaVictor Stinner2016-01-201-4/+7
|/ | | | | | | | | | | | | | | | | | | | | Issue #26107: The format of the co_lnotab attribute of code objects changes to support negative line number delta. Changes: * assemble_lnotab(): if line number delta is less than -128 or greater than 127, emit multiple (offset_delta, lineno_delta) in co_lnotab * update functions decoding co_lnotab to use signed 8-bit integers - dis.findlinestarts() - PyCode_Addr2Line() - _PyCode_CheckLineNumber() - frame_setlineno() * update lnotab_notes.txt * increase importlib MAGIC_NUMBER to 3361 * document the change in What's New in Python 3.6 * cleanup also PyCode_Optimize() to use better variable names
* Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.Serhiy Storchaka2015-12-191-1/+1
| | | | | This allows sys.getsize() to work correctly with their subclasses with __slots__ defined.
* Issue #18874: PyCode_New() now ensures that the filename is a ready UnicodeVictor Stinner2013-10-101-0/+5
| | | | | string. This change does nothing is most cases, but it is useful on Windows in some cases.
* Issue #15456: Fix code __sizeof__ after #12399 change.Martin v. Löwis2012-07-261-1/+17
| | | | Patch by Serhiy Storchaka.
* Make PyUnicode_Copy() private => _PyUnicode_Copy()Victor Stinner2011-12-121-1/+1
| | | | | | Undocument the function. Make also decode_utf8_errors() as private (static).
* Reuse PyUnicode_Copy() in validate_and_copy_tuple()Victor Stinner2011-10-111-3/+1
|
* Implement PEP 393.Martin v. Löwis2011-09-281-6/+9
|
* Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.Brian Curtin2011-08-111-2/+1
| | | | The macro was introduced in #12724.
* map cells to arg slots at code creation time (closes #12399)Benjamin Peterson2011-06-261-29/+65
| | | | This removes nested loops in PyEval_EvalCodeEx.
* Remove arbitrary string length limitsVictor Stinner2011-01-051-2/+2
| | | | | PyUnicode_FromFormat() and PyErr_Format() allocates a buffer of the needed size, it is no more a fixed-buffer of 500 bytes.
* Issue #9566: use Py_ssize_t instead of intVictor Stinner2011-01-041-2/+3
|
* make hashes always the size of pointers; introduce Py_hash_t #9778Benjamin Peterson2010-10-171-2/+2
|
* Remove unused label.Georg Brandl2010-10-151-4/+0
|
* Use locale encoding if Py_FileSystemDefaultEncoding is not setVictor Stinner2010-10-151-13/+0
| | | | | | | | * PyUnicode_EncodeFSDefault(), PyUnicode_DecodeFSDefaultAndSize() and PyUnicode_DecodeFSDefault() use the locale encoding instead of UTF-8 if Py_FileSystemDefaultEncoding is NULL * redecode_filenames() functions and _Py_code_object_list (issue #9630) are no more needed: remove them
* Issue #9630: Redecode filenames when setting the filesystem encodingVictor Stinner2010-09-291-0/+17
| | | | | | | | | | | | | | Redecode the filenames of: - all modules: __file__ and __path__ attributes - all code objects: co_filename attribute - sys.path - sys.meta_path - sys.executable - sys.path_importer_cache (keys) Keep weak references to all code objects until initfsencoding() is called, to be able to redecode co_filename attribute of all code objects.
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-453/+453
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* code_repr(): use %U to format the filenameVictor Stinner2010-05-071-8/+12
| | | | Avoid useless unicode decoding/recoding of the filename.
* Merged revisions 79060 via svnmerge fromCollin Winter2010-03-181-1/+4
| | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r79060 | collin.winter | 2010-03-18 14:54:01 -0700 (Thu, 18 Mar 2010) | 4 lines Add support for weak references to code objects. This will be used by an optimization in the incoming Python 3 JIT. Patch by Reid Kleckner! ........
* Merged revisions 72487-72488,72879 via svnmerge fromAlexandre Vassalotti2009-07-211-133/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r72487 | jeffrey.yasskin | 2009-05-08 17:51:06 -0400 (Fri, 08 May 2009) | 7 lines PyCode_NewEmpty: Most uses of PyCode_New found by http://www.google.com/codesearch?q=PyCode_New are trying to build an empty code object, usually to put it in a dummy frame object. This patch adds a PyCode_NewEmpty wrapper which lets the user specify just the filename, function name, and first line number, instead of also requiring lots of code internals. ........ r72488 | jeffrey.yasskin | 2009-05-08 18:23:21 -0400 (Fri, 08 May 2009) | 13 lines Issue 5954, PyFrame_GetLineNumber: Most uses of PyCode_Addr2Line (http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get the line number of a specified frame, but there's no way to do that directly. Forcing people to go through the code object makes them know more about the guts of the interpreter than they should need. The remaining uses of PyCode_Addr2Line seem to be getting the line from a traceback (for example, http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line), which is replaced by the tb_lineno field. So we may be able to deprecate PyCode_Addr2Line entirely for external use. ........ r72879 | jeffrey.yasskin | 2009-05-23 19:23:01 -0400 (Sat, 23 May 2009) | 14 lines Issue #6042: lnotab-based tracing is very complicated and isn't documented very well. There were at least 3 comment blocks purporting to document co_lnotab, and none did a very good job. This patch unifies them into Objects/lnotab_notes.txt which tries to completely capture the current state of affairs. I also discovered that we've attached 2 layers of patches to the basic tracing scheme. The first layer avoids jumping to instructions that don't start a line, to avoid problems in if statements and while loops. The second layer discovered that jumps backward do need to trace at instructions that don't start a line, so it added extra lnotab entries for 'while' and 'for' loops, and added a special case for backward jumps within the same line. I replaced these patches by just treating forward and backward jumps differently. ........
* #6502: add missing comma in docstring.Georg Brandl2009-07-181-1/+1
|
* Issue #1717: rename tp_compare to tp_reserved. I'll change theMark Dickinson2009-02-021-1/+1
| | | | | type of tp_compare in a separate commit, for ease of reversion should things go wrong.
* Rename PyUnicode_AsString -> _PyUnicode_AsString andMarc-André Lemburg2008-08-071-1/+1
| | | | | | | | | PyUnicode_AsStringAndSize -> _PyUnicode_AsStringAndSize to mark them for interpreter internal use only. We'll have to rework these APIs or create new ones for the purpose of accessing the UTF-8 representation of Unicode objects for 3.1.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-5/+5
|
* #1939: update code object docstring.Georg Brandl2008-01-261-2/+3
|
* Merging the py3k-pep3137 branch back into the py3k branch.Guido van Rossum2007-11-061-5/+7
| | | | | | | | | | | | | | No detailed change log; just check out the change log for the py3k-pep3137 branch. The most obvious changes: - str8 renamed to bytes (PyString at the C level); - bytes renamed to buffer (PyBytes at the C level); - PyString and PyUnicode are no longer compatible. I.e. we now have an immutable bytes type and a mutable bytes type. The behavior of PyString was modified quite a bit, to make it more bytes-like. Some changes are still on the to-do list.
* Fix a refleak for `filename', introduced in rev. 58466.Georg Brandl2007-10-241-4/+0
| | | | Also remove an unnecessary incref/decref for `name'.
* Patch #1272, by Christian Heimes and Alexandre Vassalotti.Guido van Rossum2007-10-151-11/+8
| | | | | | | | | | Changes to make __file__ a proper Unicode object, using the default filesystem encoding. This is a bit tricky because the default filesystem encoding isn't set by the time we import the first modules; at that point we fudge things a bit. This is okay since __file__ isn't really used much except for error reporting. Tested on OSX and Linux only so far.
* Ensure that code object names (co_name) are unicode.Neal Norwitz2007-08-241-5/+10
| | | | Verify that they print properly too.
* Merged revisions 56467-56482 via svnmerge fromMartin v. Löwis2007-07-211-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/p3yk ................ r56477 | martin.v.loewis | 2007-07-21 09:04:38 +0200 (Sa, 21 Jul 2007) | 11 lines Merged revisions 56466-56476 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r56476 | martin.v.loewis | 2007-07-21 08:55:02 +0200 (Sa, 21 Jul 2007) | 4 lines PEP 3123: Provide forward compatibility with Python 3.0, while keeping backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT. ........ ................ r56478 | martin.v.loewis | 2007-07-21 09:47:23 +0200 (Sa, 21 Jul 2007) | 2 lines PEP 3123: Use proper C inheritance for PyObject. ................ r56479 | martin.v.loewis | 2007-07-21 10:06:55 +0200 (Sa, 21 Jul 2007) | 3 lines Add longintrepr.h to Python.h, so that the compiler can see that PyFalse is really some kind of PyObject*. ................ r56480 | martin.v.loewis | 2007-07-21 10:47:18 +0200 (Sa, 21 Jul 2007) | 2 lines Qualify SHIFT, MASK, BASE. ................ r56482 | martin.v.loewis | 2007-07-21 19:10:57 +0200 (Sa, 21 Jul 2007) | 2 lines Correctly refer to _ob_next. ................
* Make identifiers str (not str8) objects throughout.Martin v. Löwis2007-06-101-8/+8
| | | | | | | | | | | | | | | | | | | This affects the parser, various object implementations, and all places that put identifiers into C string literals. In testing, a number of crashes occurred as code would fail when the recursion limit was reached (such as the Unicode interning dictionary having key/value pairs where key is not value). To solve these, I added an overflowed flag, which allows for 50 more recursions after the limit was reached and the exception was raised, and a recursion_critical flag, which indicates that recursion absolutely must be allowed, i.e. that a certain call must not cause a stack overflow exception. There are still some places where both str and str8 are accepted as identifiers; these should eventually be removed.
* Use PyUnicode_FromFormat() directly.Walter Dörwald2007-06-061-5/+3
|
* Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirrorWalter Dörwald2007-05-181-1/+1
| | | | | | | | | | | | | | | PyString_Concat() and PyString_ConcatAndDel() (the name PyUnicode_Concat() was already taken). Change PyObject_Repr() to always return a unicode object. Update all repr implementations to return unicode objects. Add a function PyObject_ReprStr8() that calls PyObject_Repr() and converts the result to an 8bit string. Use PyObject_ReprStr8() where using PyObject_Repr() can't be done straightforward.
* Jiwon Seo's PEP 3102 implementation.Guido van Rossum2006-10-271-5/+20
| | | | | See SF#1549670. The compiler package has not yet been updated.
* Fix a bunch of compiler warnings. In at least one case these were serious bugs!Guido van Rossum2006-08-241-7/+7
|
* Implement == and != comparisons for code objects by value.Guido van Rossum2006-08-241-39/+55
| | | | This makes test_codeop and test_marshal pass.
* Restructure comparison dramatically. There is no longer a defaultGuido van Rossum2006-08-241-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *ordering* between objects; there is only a default equality test (defined by an object being equal to itself only). Read the comment in object.c. The current implementation never uses a three-way comparison to compute a rich comparison, but it does use a rich comparison to compute a three-way comparison. I'm not quite done ripping out all the calls to PyObject_Compare/Cmp, or replacing tp_compare implementations with tp_richcompare implementations; but much of that has happened (to make most unit tests pass). The following tests still fail, because I need help deciding or understanding: test_codeop -- depends on comparing code objects test_datetime -- need Tim Peters' opinion test_marshal -- depends on comparing code objects test_mutants -- need help understanding it The problem with test_codeop and test_marshal is this: these tests compare two different code objects and expect them to be equal. Is that still a feature we'd like to support? I've temporarily removed the comparison and hash code from code objects, so they use the default (equality by pointer only) comparison. For the other two tests, run them to see for yourself. (There may be more failing test with "-u all".) A general problem with getting lots of these tests to pass is the reality that for object types that have a natural total ordering, implementing __cmp__ is much more convenient than implementing __eq__, __ne__, __lt__, and so on. Should we go back to allowing __cmp__ to provide a total ordering? Should we provide some other way to implement rich comparison with a single method override? Alex proposed a __key__() method; I've considered a __richcmp__() method. Or perhaps __cmp__() just shouldn't be killed off...