Nadeem Vawda
8f46d655b9
Fix typo in changeset eb5c5c23ca9b.
2012-05-05 12:27:30 +02:00
Brett Cannon
feccc09952
Clean up a docstring.
2012-05-04 16:47:54 -04:00
Antoine Pitrou
f3a42dee9a
Simplify code for load_dynamic()
2012-05-04 22:40:25 +02:00
Brett Cannon
0429e1a57d
Issue #13959 : Move module type constants to Lib/imp.py.
2012-05-04 16:13:30 -04:00
Brett Cannon
6b9b727695
Remove dead Windows code which no longer will compile.
2012-05-04 16:04:14 -04:00
Brett Cannon
a6685e8d36
update importlib.h
2012-05-04 16:03:20 -04:00
Brett Cannon
2657df4744
Issue #13959 : Re-implement imp.get_suffixes() in Lib/imp.py.
...
This introduces a new function, imp.extension_suffixes(), which is
currently undocumented. That is forthcoming once issue #14657 is
resolved and how to expose file suffixes is decided.
2012-05-04 15:20:40 -04:00
Larry Hastings
76ad59b7e8
Issue #14127 : Add ns= parameter to utime, futimes, and lutimes.
...
Removed futimens as it is now redundant.
Changed shutil.copystat to use st_atime_ns and st_mtime_ns from os.stat
and ns= parameter to utime--it once again preserves exact metadata on Linux!
2012-05-03 00:30:07 -07:00
Benjamin Peterson
49a69e4d48
strip is_ prefixes on clock_info fields
2012-05-01 09:38:34 -04:00
Brett Cannon
62228dbd6c
Issues #13959 , 14647: Re-implement imp.reload() in Lib/imp.py.
...
Thanks to Eric Snow for the patch.
2012-04-29 14:38:11 -04:00
Brett Cannon
acf85cd131
Issue #13959 : Re-implement imp.NullImporter in Lib/imp.py.
2012-04-29 12:50:03 -04:00
Mark Dickinson
e383e82e04
Issue #14521 : Make result of float('nan') and float('-nan') more consistent across platforms. Further, don't rely on Py_HUGE_VAL for float('inf').
2012-04-29 15:31:56 +01:00
Victor Stinner
ec89539ccc
Issue #14428 , #14397 : Implement the PEP 418
...
* Rename time.steady() to time.monotonic()
* On Windows, time.monotonic() uses GetTickCount/GetTickCount64() instead of
QueryPerformanceCounter()
* time.monotonic() uses CLOCK_HIGHRES if available
* Add time.get_clock_info(), time.perf_counter() and time.process_time()
functions
2012-04-29 02:41:27 +02:00
Brett Cannon
efad00d520
Issue #14646 : __import__() now sets __loader__ if need be.
...
importlib.util.module_for_loader also will set __loader__ along with
__package__. This is in conjunction to a forthcoming update to PEP 302
which will make these two attributes required for loaders to set.
2012-04-27 17:27:14 -04:00
Brett Cannon
fea73efc9e
Issue #14605 : Don't error out if get_importer() returns None.
2012-04-27 15:45:15 -04:00
Brett Cannon
aa93642a35
Issue #14605 : Use None in sys.path_importer_cache to represent no
...
finder instead of using some (now non-existent) implicit finder.
2012-04-27 15:30:58 -04:00
Brett Cannon
ce418b448f
Issue #14605 : Stop having implicit entries for sys.meta_path.
...
ImportWarning is raised if sys.meta_path is found to be empty.
2012-04-27 14:01:58 -04:00
Victor Stinner
8f825060f1
Check newly created consistency using _PyUnicode_CheckConsistency(str, 1)
...
* In debug mode, fill the string data with invalid characters
* Simplify also reference counting in PyCodec_BackslashReplaceErrors()
and PyCodec_XMLCharRefReplaceError()
2012-04-27 13:55:39 +02:00
Benjamin Peterson
9fa47ebafe
merge heads
2012-04-26 00:27:06 -04:00
Benjamin Peterson
1138944888
only incref when using borrowing functions
2012-04-26 00:26:37 -04:00
Brett Cannon
e0d88a173c
Issue #14605 : Make explicit the entries on sys.path_hooks that used to
...
be implicit.
Added a warning for when sys.path_hooks is found to be empty. Also
changed the meaning of None in sys.path_importer_cache to represent
trying sys.path_hooks again (an interpretation of previous semantics).
Also added a warning for when None was found.
The long-term goal is for None in sys.path_importer_cache to represent
the same as imp.NullImporter: no finder found for that sys.path entry.
2012-04-25 20:54:04 -04:00
Brett Cannon
f96bb2f9af
Update importlib.h
2012-04-25 20:18:55 -04:00
Brett Cannon
5a5d6a1033
Merge
2012-04-25 20:18:24 -04:00
Marc-Andre Lemburg
7541c8ea37
Issue #14605 and #14642 :
...
Issue a warning in case Python\importlib.h needs to be rebuilt,
but there's no Python interpreter around to freeze the bootstrap
script.
2012-04-25 10:54:48 +02:00
Brett Cannon
8923a4d4c5
Issue #14605 : Insert to the front of sys.path_hooks instead of appending.
2012-04-24 22:03:46 -04:00
Marc-Andre Lemburg
4fe29c9657
Issue #14605 : Rename _SourcelessFileLoader to SourcelessFileLoader.
...
This time also recreating the Python/importlib.h file to make
make happy. See the ticket for details.
2012-04-25 02:31:37 +02:00
Victor Stinner
ece58deb9f
Close #14648 : Compute correctly maxchar in str.format() for substrin
2012-04-23 23:36:38 +02:00
Benjamin Peterson
7d95e40721
Implement PEP 412: Key-sharing dictionaries ( closes #13903 )
...
Patch from Mark Shannon.
2012-04-23 11:24:50 -04:00
Benjamin Peterson
80d07f8251
inherit maxchar of field value where needed ( closes #14648 )
2012-04-23 10:55:29 -04:00
Brett Cannon
938d44d59c
Issue #14605 : Expose importlib.abc.FileLoader and
...
importlib.machinery.(FileFinder, SourceFileLoader,
_SourcelessFileLoader, ExtensionFileLoader).
This exposes all of importlib's mechanisms that will become public on
the sys module.
2012-04-22 19:58:33 -04:00
Brett Cannon
5c903e6ee1
Issue #13959 : Continue to try to accomodate altsep in importlib by not
...
ignoring altsep if it already exists on a path when doing a join.
2012-04-22 11:45:07 -04:00
Brett Cannon
cf649958f7
Revert to os.path.join() semantics for path manipulation in importlib
...
which is different than what imp.cache_from_source() operates on.
2012-04-22 02:06:23 -04:00
Brett Cannon
6c802b8491
Update importlib.h
2012-04-21 21:47:08 -04:00
Brett Cannon
0d05a7698b
Have importlib look for pre-existing path separators when joining
...
paths.
2012-04-21 21:21:27 -04:00
Brett Cannon
e69f0df45b
Issue #13959 : Re-implement imp.find_module() in Lib/imp.py.
...
Thanks to Eric Snow for taking an initial stab at the implementation.
2012-04-21 21:09:46 -04:00
Brett Cannon
2f92389d5c
Don't worry about moving imp.get_tag() over to Lib/imp.py.
2012-04-21 18:55:51 -04:00
Brett Cannon
a64faf0771
Issue #13959 : Re-implement imp.source_from_cache() in Lib/imp.py.
2012-04-21 18:52:52 -04:00
Brett Cannon
ea59dbff16
Issue #13959 : Re-implement imp.cache_from_source() in Lib/imp.py.
2012-04-20 21:44:46 -04:00
Brett Cannon
ed672d6872
Make path manipulation more robust for platforms with alternative path
...
separators.
2012-04-20 21:19:53 -04:00
Brett Cannon
24117a748b
Issue #13959 : Keep imp.get_magic() in C code, but cache in importlib
...
for performance. While get_magic() could move to Lib/imp.py, having to
support PyImport_GetMagicNumber() would lead to equal, if not more, C
code than sticking with the status quo.
2012-04-20 18:04:03 -04:00
Brett Cannon
3dfc22cc04
Issue #14599 : Support ImportError.path on AIX and HPUX when loading
...
extension modules.
2012-04-20 15:31:11 -04:00
Brett Cannon
f0434e647a
Issue #14599 : Generalize a test for ImportError.path and add support
...
in Python/dynload_shlibs.c.
This should fix the remaining importlib test failure on Windows.
Support in AIX and HP-UX will be in a separate checkin.
2012-04-20 15:22:50 -04:00
Brett Cannon
8ff6baf25b
Issue #14581 : Windows users are allowed to import modules w/o taking
...
the file suffix's case into account, even when doing a case-sensitive
import.
2012-04-20 12:53:14 -04:00
Larry Hastings
6fe20b3aee
Issue #14127 : Add st_{cma}time_ns fields to os.stat() result object.
2012-04-19 15:07:49 -07:00
Antoine Pitrou
bf35c156b4
Fix refleak: PyObject_GetItem returns a new reference, not a borrowed one like PyDict_GetItem.
2012-04-19 18:21:04 +02:00
Martin v. Löwis
aa2efcb0bc
Issue #14098 : New functions PyErr_GetExcInfo and PyErr_SetExcInfo.
...
Patch by Stefan Behnel.
2012-04-19 14:33:43 +02:00
Victor Stinner
b0b224233e
Issue #14385 : Support other types than dict for __builtins__
...
It is now possible to use a custom type for the __builtins__ namespace, instead
of a dict. It can be used for sandboxing for example. Raise also a NameError
instead of ImportError if __build_class__ name if not found in __builtins__.
2012-04-19 00:57:45 +02:00
Benjamin Peterson
665c3b3eec
update importlib...
2012-04-18 15:29:52 -04:00
Antoine Pitrou
eca851815d
Merge heads
2012-04-18 16:59:52 +02:00
Antoine Pitrou
ec9bac4226
Fix it for good :-)
2012-04-18 16:57:54 +02:00
Benjamin Peterson
d76bc7abac
rollback 005fd1fe31ab (see #14609 and #14582 )
...
Being able to overload a sys.module entry during import of a module was broken
by this changeset.
2012-04-18 10:55:43 -04:00
Benjamin Peterson
da20cd2b6b
fix refcnt/style/debuging oversights
2012-04-18 10:48:00 -04:00
Brian Curtin
94c001b503
Fix email post-commit review comments.
...
Add INCREFs, fix args->kwargs, and a second args==NULL check was removed,
left over from a merger with another function. Instead, checking msg==NULL
does what that used to do in a roundabout way.
2012-04-18 08:30:51 -05:00
Brett Cannon
03c7ed1580
Merge
2012-04-17 21:42:07 -04:00
Brett Cannon
7bd329d800
Issue #12599 : Be more strict in accepting None vs. a false-like object
...
in importlib.
Thanks to PJE for pointing out the issue and Nick Coghlan for filing
the bug.
2012-04-17 21:41:35 -04:00
Benjamin Peterson
2a1fdc4c76
merge 3.2 ( #14607 )
2012-04-17 19:54:35 -04:00
Benjamin Peterson
32c59b6fc1
mangle keyword-only argname when loading defaults ( closes #14607 )
2012-04-17 19:53:21 -04:00
Brett Cannon
64befe939c
Issue #13959 : Re-implement imp.load_compiled() in imp.py.
2012-04-17 19:14:26 -04:00
Brett Cannon
273323cf68
Issue #14592 : A relative import will raise a KeyError if __package__
...
or __name__ are not set in globals.
Thanks to Stefan Behnel for the bug report.
2012-04-17 19:05:11 -04:00
Brian Curtin
09b86d1196
Fix #14600 . Correct reference handling and naming of ImportError convenience function
2012-04-17 16:57:09 -05:00
Brett Cannon
16475adcbb
Issue #13959 : Re-implement imp.load_source() in imp.py.
2012-04-16 22:11:25 -04:00
Antoine Pitrou
22a1d17bb5
Fix another refleak
2012-04-16 22:06:21 +02:00
Antoine Pitrou
538ba2afb5
Fix a refleak
2012-04-16 21:52:45 +02:00
Antoine Pitrou
71382cb64b
Fix reference loss on Py_None when None is encountered in sys.modules.
2012-04-16 18:48:49 +02:00
Antoine Pitrou
a938c74751
Avoid compiler warning due to stray \x00
2012-04-16 18:30:54 +02:00
Brian Curtin
b206a80dab
Fix #10854 . Make use of the new path and name attributes on ImportError
...
for extension modules on Windows.
2012-04-16 00:10:17 -05:00
Brett Cannon
2ee61422ed
Issue #13959 : Re-implement imp.load_package() in imp.py.
...
Thanks to Eric Snow for helping with imp.load_module() (previous
commit) which led to the removal of a bunch of C code.
2012-04-15 22:28:28 -04:00
Brett Cannon
01a76171a0
Issue #13959 : Re-implement imp.load_module() in imp.py.
2012-04-15 20:25:23 -04:00
Brett Cannon
c1b3f63653
Try to get hg to treat importlib.h as binary.
2012-04-15 19:05:31 -04:00
Brett Cannon
8a1d04c643
Issue #13959 : Simplify imp.reload() by relying on a module's
...
__loader__.
Since import now sets __loader__ on all modules it creates and
imp.reload() already relied on the attribute for modules that import
didn't create, the only potential compatibility issue is if people
were deleting the attribute on modules and expecting imp.reload() to
continue to work.
2012-04-15 17:56:09 -04:00
Brett Cannon
7ceedb8c1e
Update importlib.h
2012-04-15 17:47:19 -04:00
Brett Cannon
6f44d66bc4
Issue #13959 : Rename imp to _imp and add Lib/imp.py and begin
...
rewriting functionality in pure Python.
To start, imp.new_module() has been rewritten in pure Python, put into
importlib (privately) and then publicly exposed in imp.
2012-04-15 16:08:47 -04:00
Brett Cannon
881535b726
Issue #14582 : Import returns the module returned by a loader instead
...
of sys.modules when possible.
This is being done for two reasons. One is to gain a little bit of
performance by skipping an unnecessary dict lookup in sys.modules. But
the other (and main) reason is to be a little bit more clear in how
things should work from the perspective of import's interactions with
loaders. Otherwise loaders can easily forget to return the module even
though PEP 302 explicitly states they are expected to return the module
they loaded.
2012-04-15 15:24:04 -04:00
Brett Cannon
27fc52877c
Set ImportError.name when raising the exception in the case of None
...
found in sys.modules.
2012-04-15 14:15:31 -04:00
Brett Cannon
fc9ca274b8
Plug a refleak.
2012-04-15 01:35:05 -04:00
Brett Cannon
49f8d8b016
Handle importing pkg.mod by executing
...
__import__('mod', {'__packaging__': 'pkg', level=1) w/o properly (and
thus not segfaulting).
2012-04-14 21:50:00 -04:00
Brett Cannon
59f9c3affc
Rebuild importlib.h to incorporate added comments.
2012-04-14 21:18:48 -04:00
Brian Curtin
e6b299faf5
Fix Windows build
2012-04-14 14:19:33 -05:00
Brett Cannon
740fce0e38
Undo a C99 idiom.
2012-04-14 14:23:49 -04:00
Brett Cannon
fd0741555b
Issue #2377 : Make importlib the implementation of __import__().
...
importlib._bootstrap is now frozen into Python/importlib.h and stored
as _frozen_importlib in sys.modules. Py_Initialize() loads the frozen
code along with sys and imp and then uses _frozen_importlib._install()
to set builtins.__import__() w/ _frozen_importlib.__import__().
2012-04-14 14:10:13 -04:00
Benjamin Peterson
780b66b3e6
merge 3.2
2012-04-13 18:06:42 -04:00
Benjamin Peterson
3bf01757b6
move outside WITH_THREAD conditional
2012-04-13 18:06:36 -04:00
Benjamin Peterson
899ee613f7
merge 3.2
2012-04-13 11:59:52 -04:00
Benjamin Peterson
43162b8a02
take linkage def outside of WITH_THREAD conditional ( closes #14569 )
2012-04-13 11:58:27 -04:00
Brett Cannon
79ec55e980
Issue #1559549 : Add 'name' and 'path' attributes to ImportError.
...
Currently import does not use these attributes as they are planned
for use by importlib (which will be another commit).
Thanks to Filip Gruszczyński for the initial patch and Brian Curtin
for refining it.
2012-04-12 20:24:54 -04:00
Kristján Valur Jónsson
31668b8f7a
Issue #14288 : Serialization support for builtin iterators.
2012-04-03 10:49:41 +00:00
Benjamin Peterson
0a9a636302
merge 3.2
2012-04-03 00:35:36 -04:00
Benjamin Peterson
80d50428ce
fix parse_syntax_error to clean up its resources
2012-04-03 00:30:38 -04:00
Brett Cannon
368b4b7405
Guard an LLTRACE variable to silence an unused variable warning.
2012-04-02 12:17:59 -04:00
Victor Stinner
3c1e48176e
Issue #14383 : Add _PyDict_GetItemId() and _PyDict_SetItemId() functions
...
These functions simplify the usage of static constant Unicode strings.
Generalize the usage of _Py_Identifier in ceval.c and typeobject.c.
2012-03-26 22:10:51 +02:00
Kristján Valur Jónsson
4b0215fd99
Merge with 3.2
2012-03-23 12:52:11 +00:00
Kristján Valur Jónsson
c5d47d5ac3
Fix typo when "PyObject*" was changed to "identifier"
2012-03-23 12:50:53 +00:00
Benjamin Peterson
cc58031d6a
merge 3.2
2012-03-22 10:40:20 -04:00
Benjamin Peterson
9faf5ee750
this should technicaly be identifier
2012-03-22 10:39:16 -04:00
Benjamin Peterson
b304764ba2
merge 3.2
2012-03-22 08:56:27 -04:00
Benjamin Peterson
ab79c71f39
check for NULL
2012-03-22 08:56:15 -04:00
Benjamin Peterson
98ba753432
merge 3.2 ( #14378 )
2012-03-22 08:19:50 -04:00
Benjamin Peterson
a4e4e35783
check by equality for __future__ not identity ( closes #14378 )
2012-03-22 08:19:04 -04:00
Benjamin Peterson
302e7902c8
use identifier api
2012-03-20 23:17:04 -04:00
Larry Hastings
83a9f48699
Issue #14328 : Add keyword-only parameters to PyArg_ParseTupleAndKeywords.
...
They're optional-only for now (unlike in pure Python) but that's all
I needed. The syntax can easily be relaxed if we want to support
required keyword-only arguments for extension types in the future.
2012-03-20 20:06:16 +00:00