Stefan Behnel added the comment:
I understand that this is not trivial to test as part of the regression test
suite. However, when I try it now I get this:
Traceback (most recent call last):
File "", line 1, in
File "__init__.py", line 8, in init my_test_package
(my_t
Stefan Behnel added the comment:
Hmm, yes, sounds more like a separate issue than something to add to this
ticket. It worked before (starting with Py2.5, which was the first Python
version to support relative imports) and only stopped working in 3.3 now.
The .srctree test file basically just
New submission from Stefan Behnel:
Since CPython 2.5, relative imports could be used from __init__.so package
modules. This stopped working in CPython 3.3.
This is a follow-up ticket to issue15576.
This feature is exercised by Cython's initial_file_path test, which now gives
this r
Stefan Behnel added the comment:
I've created issue15623, so that we can keep this one as fixed.
--
resolution: -> fixed
status: open -> closed
___
Python tracker
<http://bugs.python.
Stefan Behnel added the comment:
We are continuously testing Cython against all CPython versions starting from
2.4, so I can assure you that it's still working for all other versions. Here's
our CI server:
https://sage.math.washington.edu:8091/hudson/job/cython-devel-tests/618/
I
Stefan Behnel added the comment:
That's the module init code, yes, including the setting of __file__ and
__path__ that I mentioned (due to issue13429). Setting at least one of the two
is required in previous CPython versions to make relative imports
Stefan Behnel added the comment:
Interesting. I didn't know that. The .py file is always installed automatically
next to the .so file by distutils.
Here's what strace gives me:
Python 2.7:
stat("my_test_package", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
stat("
Stefan Behnel added the comment:
I tried it and it works to just insert the package module into sys.modules
after creation if it's not there yet:
#if PY_MAJOR_VERSION < 3
__pyx_m = Py_InitModule4(__Pyx_NAMESTR("my_test_package"), __pyx_methods, 0,
0, PYTHON_API_VERSION);
Stefan Behnel added the comment:
To add on Dag's comments, this essentially means that any caching of the hash
value is dangerous, unless it can be assured that the underlying buffer
definitely has not changed in the meantime. There is no way for users to
explicitly tell a memoryvi
New submission from Stefan Behnel:
Formatting support for "lld"/"llu" was added (I think) in issue 7228, but the
definition of PY_FORMAT_SIZE_T wasn't adapted. We are getting test output
failures in Cython on Win64 when formatting error messages using the "Id&qu
Stefan Behnel added the comment:
I just saw that we were misusing PY_FORMAT_SIZE_T according to the
documentation (reading that sometimes helps...). It is not supposed to be used
with the Python formatting functions, only with low-level functions.
Closing, sorry for the noise
Changes by Stefan Behnel :
--
nosy: -scoder
___
Python tracker
<http://bugs.python.org/issue15814>
___
___
Python-bugs-list mailing list
Unsubscribe:
Stefan Behnel added the comment:
Agreed that this should be done. The XInclude spec suggests that the processing
is transitive. Also, lxml does it that way, in both the libxml2 based
implementation and the ElementInclude compatibility module.
https://github.com/lxml/lxml/blob/master/src/lxml
Stefan Behnel added the comment:
catalog = xml.etree.ElementTree.parse('books.xml')
# This succeeds
for book in catalog.findall('book'):
print(book.tag)
This is a bit of a convenience break in the API. The "normal" way to do it
would be either c
Stefan Behnel added the comment:
I think you attached the wrong file.
--
___
Python tracker
<http://bugs.python.org/issue20375>
___
___
Python-bugs-list mailin
Stefan Behnel added the comment:
> Add all the element methods to the elementtree object.
Ok, but why? An ElementTree object *is not* an Element. It's a
representation of a document that *has* a root Element.
It makes sense for a document to allow searches over its content, and the
Ele
Stefan Behnel added the comment:
> I don't see any benefit from having this code fail:
>
> from xml.etree.ElementTree import parse
>
> catalog = parse('books.xml')
> for book in catalog:
> print book.get('id')
Why would you
Stefan Behnel added the comment:
> How about just making a sensibly-behaving __iter__ for ElementTree?
Well, the problem is to determine what "sensibly-behaving" is. I can see
three options.
1) tree.iter() == tree.getroot().iter()
2) iter(tree.getroot())
3) iter([tree.get
Stefan Behnel added the comment:
@gene_wood: that's unrelated. This ticket is about attributes being rejected
incorrectly.
Fixing the example of the OP:
>>> from xml.etree.ElementTree import *
>>> svg = ElementTree(XML("""
... htt
Stefan Behnel added the comment:
You can already use iterparse for this.
it = ET.iterparse('somefile.xml')
for _, el in it:
el.tag = el.tag.split('}', 1)[1] # strip all namespaces
root = it.root
As I said, this would be a little friendlier with suppor
Stefan Behnel added the comment:
Works for me in 3.2 and 3.4, fails in 2.7, as reported.
I'll leave it to Eli to decide if this should get fixed in 2.7. In Py2, ET and
cET were different modules, so this could also be considered a missing feature
in cET. Given that it leads to a serialis
Stefan Behnel added the comment:
Ah, sorry, actually, it does not work in Py3.2:
>>> import xml.etree.cElementTree as cET
>>> root = cET.Element('root', attrib={'Name':'Root'})
>>> child = cET.SubElement(root, 'child', attrib={
Stefan Behnel added the comment:
According to issue 1572710, this is not a bug. The "attrib" argument is
supposed to be a positional argument, not a keyword argument. This makes sense,
given that arbitrary keyword arguments are accepted for additional XML
Stefan Behnel added the comment:
Note that this has been fixed in Py3 already (Py3.3, I guess). The only
question is whether the behaviour will be changed in Py2.7.
--
components: -XML
___
Python tracker
<http://bugs.python.org/issue21
Stefan Behnel added the comment:
LGTM, can't see a case where this might go wrong (errors and type checks are
handled before the added code).
It also seems a sufficiently common case to optimise it internally. The 2**n
spelling is easier to read and to get right than the shifting, so
Stefan Behnel added the comment:
The "avoid rebuilding" part doesn't seem to work for me. Source build currently
fails as follows:
"""
/bin/mkdir -p Include
python ./Parser/asdl_c.py -h Include ./Parser/Python.asdl
# Substitution happens here, as the compl
Stefan Behnel added the comment:
That fixes it. Thanks!
--
___
Python tracker
<http://bugs.python.org/issue19655>
___
___
Python-bugs-list mailing list
Unsub
Stefan Behnel added the comment:
I tried the same with a Cython compiled version of select.py in the latest
CPython 3.5 build. It pretty clearly shows that select2 is pretty much always
faster than sorting, by a factor of 2-5x or so. I'll also attach the annotated
source file that C
Changes by Stefan Behnel :
Added file: http://bugs.python.org/file35427/select.html
___
Python tracker
<http://bugs.python.org/issue21592>
___
___
Python-bugs-list mailin
Stefan Behnel added the comment:
Here's also the pathological "average of three calls" case. As Steven suggests,
it shows that select() suffers quite heavily (algorithmically), but select2()
also suffers enough to jump up to about 2/3 of the runtime of sorting (so it's
s
Stefan Behnel added the comment:
Updating the type declaration file to remove the dependency on the list builtin
and allow arbitrary containers. The test code has this dependency (calls
a.sort()), but the current statistics module in the stdlib does not (calls
sorted()). Timings do not change
Changes by Stefan Behnel :
Added file: http://bugs.python.org/file35430/select.html
___
Python tracker
<http://bugs.python.org/issue21592>
___
___
Python-bugs-list mailin
New submission from Stefan Behnel:
After compiling the stdlib with Cython with the attached script, modules that
use circular imports fail to initialise. That includes os and posixpath, as
well as shutil and tarfile. Example:
$ ./python -c 'import shutil'
Traceback (most recent
New submission from Stefan Behnel:
My guess is that line 454 in pkgutil.py should pass "pkg_name" into the
import_module() function, not "pkg". I get the following error when compiling
it with Cython:
Error c
Stefan Behnel added the comment:
Well, it's not like the setup was all that difficult. 1) Install the latest
github master of Cython (they provide one-click archives that pip can install
for you), 2) change into the CPython stdlib directory and run the script I
attached, 3) execute "
Changes by Stefan Behnel :
Added file: http://bugs.python.org/file27865/cystdlibbug.py
___
Python tracker
<http://bugs.python.org/issue16392>
___
___
Python-bugs-list m
Stefan Behnel added the comment:
Since it's quite possible that this has nothing to do with the frozen part of
the importlib specifically, I'm removing that bit from the ticket title.
--
title: frozen importlib crashes on circular imports in ext modules -> import
crashe
Stefan Behnel added the comment:
Hmm, we already do that for packages (i.e. when compiling __init__.py). Looks
like this just needs to be done for all modules in Py3. And unless there is a
compelling reason for Py_InitModule4() not to do it, I think it should be
reverted to its Py2 behaviour
Stefan Behnel added the comment:
Now that you mention it - wouldn't that suffer from not actually knowing the
FQMN? There's that hack in the dynlib loader that stores the package context in
a global variable so that the module creation function can figure it out. That
might be a rea
Stefan Behnel added the comment:
The problem is a) that the module does not necessarily know to which place it
eventually gets installed (Cython relies on the distutils Extension not lying
to it, for example, which people do from time to time), and b) that the call to
Py_InitModule() only
Stefan Behnel added the comment:
Agreed. Since it doesn't really fit into any specific function documentation, I
would place it right at the top. Something like this:
"""
The following functions can be used by C code to call into Python's import
machinery.
No
Stefan Behnel added the comment:
I'm increasing the target version as this didn't change anything for 3.3.
However, for 3.4, it might be possible to work around this by splitting the
module init function into two parts, one that gets executed in order to create
the module object (a
Stefan Behnel added the comment:
Triggered discussion on python-dev:
http://thread.gmane.org/gmane.comp.python.devel/135764
--
___
Python tracker
<http://bugs.python.org/issue13
Stefan Behnel added the comment:
Just for the record, I've compiled Raymond's roadmap version in Cython (with
only slight changes to make 'self.maxsize' a Py_ssize_t and using an external
.pxd for typing) and ran Serhiy's benchmark over it (Ubuntu 12.10, 64bit). Thi
Stefan Behnel added the comment:
Any news on this?
--
___
Python tracker
<http://bugs.python.org/issue11379>
___
___
Python-bugs-list mailing list
Unsubscribe:
Stefan Behnel added the comment:
Yep, I basically didn't do any optimisation, it's the plain Python code
compiled, just with the class being converted into an extension type.
--
___
Python tracker
<http://bugs.python.o
New submission from Stefan Behnel:
Line 522 in test file Lib/test/test_pep380.py says:
trace.append("Should not have yielded:", y)
However, 'trace' is a list and list.append() only takes one parameter, so this
should read:
trace.append(&quo
Stefan Behnel added the comment:
If runtime checks are needed to prevent mixing arbitrary objects into the tree,
then I don't think they should be considered too costly.
I agree with Florent that this is worth reopening. It doesn't look like a
"Tests" bug to me rath
Stefan Behnel added the comment:
FWIW, PyPy has an (R)Python implementation already:
https://bitbucket.org/pypy/pypy/src/default/pypy/rlib/rrandom.py
--
nosy: +scoder
___
Python tracker
<http://bugs.python.org/issue16
New submission from Stefan Behnel:
There's a bug originally report for lxml that also applies to ElementTree:
https://github.com/lxml/lxml/issues/95
Passing different namespace mappings into the Element.find*() methods will
always reuse the first one due to incorrect caching based only o
Changes by Stefan Behnel :
--
components: +Library (Lib) -XML
___
Python tracker
<http://bugs.python.org/issue17011>
___
___
Python-bugs-list mailing list
Unsub
Changes by Stefan Behnel :
--
components: +XML
___
Python tracker
<http://bugs.python.org/issue17011>
___
___
Python-bugs-list mailing list
Unsubscribe:
Stefan Behnel added the comment:
Here is a test case (for lxml):
https://github.com/lxml/lxml/commit/76f2ee991afd15d4f8c98cee3e095967bbf9937f
--
___
Python tracker
<http://bugs.python.org/issue17
Stefan Behnel added the comment:
I'm not sure if it's a good idea to keep bikeshedding about this for another
two years. Personally, I would prefer having someone with commit rights fix
this and be done with it.
Eric's last patch looks ok and parts of it went in already, so i
New submission from Stefan Behnel:
The following compatibility unit test fails for me in lxml since Py3.3.
etree = xml.etree.ElementTree
def test_parser_target_error_in_start(self):
assertEqual = self.assertEqual
events = []
class Target(object
Stefan Behnel added the comment:
I agree that [0] should be treated as a visible error as it's easy to get
wrong. It's certainly too late to change this to 0-based indexing and I think
it's ok to keep it 1-based for XPath compatibility (or at least similarity) as
that
Stefan Behnel added the comment:
Yes, I think it makes sense to be rigid now and *maybe* add a new feature later.
--
___
Python tracker
<http://bugs.python.org/issue12
Stefan Behnel added the comment:
This is a duplicate of issue 9518 (or the other way round) and should be closed
as fixed in 3.2.
--
components: +Extension Modules
nosy: +scoder
___
Python tracker
<http://bugs.python.org/issue7
New submission from Stefan Behnel:
I can't see a reason why Signature.from_function() should explicitly check the
type of the object being passed in. As long as the object has all required
attributes, it should be accepted.
This is specifically an issue with Cython compiled functions,
Stefan Behnel added the comment:
This patch removes the type check from Signature.from_function() and cleans up
the type tests in signature() to use whatever the inspect module defines as
isfunction() and isbuiltin(), so that it becomes properly monkey-patchable.
It also adds a test that
Stefan Behnel added the comment:
The method doesn't seem to be documented, and I'm not sure if the docstring
really benefits from this lengthy addition. Anyway, here's a patch that
includes the docstring update.
The exception could be kept the same if we catch an Att
Stefan Behnel added the comment:
Fine with me. Updated patch attached.
--
Added file: http://bugs.python.org/file29007/inspect_sig_2.patch
___
Python tracker
<http://bugs.python.org/issue17
Stefan Behnel added the comment:
Any more comments? Any objections to applying the last patch? Anyone ready to
do it?
--
___
Python tracker
<http://bugs.python.org/issue17
Stefan Behnel added the comment:
1) that's a regex test, so it just looks for the text. I only extended it to
include the object it's supposed to test for. It's not actually related to my
changes, but I considered it the right thing to do. I used "42.*is not" in
order
Stefan Behnel added the comment:
ping - I would like to see this fixed for alpha3, which is due in two weeks.
--
___
Python tracker
<http://bugs.python.org/issue18
Stefan Behnel added the comment:
The way the XMLPullParser is implemented in lxml.etree now is that it simply
inherits from XMLParser. This would also make sense for ElementTree, even
before supporting arbitrary targets. The patch in ticket #18990 makes this
simple to do.
For reference, here
Stefan Behnel added the comment:
The way the XMLPullParser is implemented in lxml.etree now is that it simply
inherits from XMLParser. This would also make sense for ElementTree, even
before supporting arbitrary targets. The patch in ticket #18990 makes this
simple to do.
For reference, here
Stefan Behnel added the comment:
> Also, +1 for allowing start-ns and end-ns event callbacks on parser targets,
> although that's a different feature entirely.
Actually, I take that back. I can't see a use case for this feature, and it
doesn't really fit with the notion o
Stefan Behnel added the comment:
I created a separate ticket #19010 for the inheritance issue.
--
___
Python tracker
<http://bugs.python.org/issue18902>
___
___
New submission from Stefan Behnel:
As mentioned in tickets #18902 and #17741, the XMLPullParser in the external
lxml.etree package inherits from the existing XMLParser class. This makes the
interface simpler, both simpler to explain and to implement.
The implementation in ElementTree should
Stefan Behnel added the comment:
I've updated the lxml documentation to reflect the new implementation. It also
has a couple of examples that show how the API works now.
https://github.com/lxml/lxml/blob/74ab4b10176750e7797eb0eff3c7c91901ab6adb/doc/parsing.txt
Stefan Behnel added the comment:
I don't think I have my head deep enough in the encodings implementation to say
that this is the correct/best way to do it, but the patch looks mostly
reasonable to me and would be a helpful addition.
I have two comments on the pyexpat_encoding_co
Stefan Behnel added the comment:
Inviting some more people to get this patch reviewed in a timely fashion. Given
that it's a cleanup of a newly introduced API, it must go in before the first
beta release of 3.4.
The even wider cleanup would be to make XMLPullParser inherit from XMLParser
Stefan Behnel added the comment:
I'm not entirely happy about the docs anyway. Most people just want to loop
over iterparse() and be done (use case being to save memory). The new parser
class is a rather special and more complex thing that we shouldn't let innocent
users run into t
Stefan Behnel added the comment:
Ah, right - I forgot that it currently only implements a part of the parser API
in ElementTree. Adding "Returns the toplevel document element." behind the
current sentence would do, I guess. That will need updating once the
XMLPullParser implements s
Stefan Behnel added the comment:
> Just as an example: consider that in a lot of use cases the programmer will
> want to discard parts of the tree that's parsed iteratively (similarly to the
> main use case of iterparse()), because the XML itself is too huge. It's a
> co
Stefan Behnel added the comment:
Eli, seeing our discussion so far, ISTM that the parser-target interface is at
the very heart of our disagreement.
For me, it's a good design that provides a clean separation of concerns between
the parser that generates events, and the target (usually
Stefan Behnel added the comment:
> That means the patch could be simplified to just removing the root
> attribute without changing the result of calling close().
Absolutely.
Returning the parse result from close() would still make it both more
consistent and easier to use (also from
Stefan Behnel added the comment:
> Unfortunately I don't have time to review refactoring patches now. In light
> of a larger refactoring planned in this part of the module in the future, I
> don't think it's very important to tweak things right now.
You misunderst
Stefan Behnel added the comment:
> I still consider this refactoring gratuitious at this point. The API is
> well defined by the documentation. All the rest is implementation details.
Famous last words.
--
___
Python tracker
<http://bugs.p
Stefan Behnel added the comment:
Here's the obvious minimal patch that removes the non-public 'root' attribute.
Please apply it for Py3.4 and then set the version tag of this ticket to Py3.5
(instead of closing it, because it's not resolved yet).
As I said, the expected t
New submission from Stefan Behnel:
The perf.py script opens the file for CSV output in binary mode, which no
longer works in Py3:
Index: perf.py
===
--- perf.py (Revision 80409)
+++ perf.py (Arbeitskopie)
@@ -2443,7
Changes by Stefan Behnel :
--
nosy: +brett.cannon, pitrou
___
Python tracker
<http://bugs.python.org/issue19107>
___
___
Python-bugs-list mailing list
Unsub
New submission from Stefan Behnel:
In changeset 88b6ef9aa9e9, a new function ported_lib() was added that crashes
on error reporting in Py3 because it tries to do this:
raise RuntimeError("Benchmark died: " + err)
"err" is a bytes object that comes straight from the s
Stefan Behnel added the comment:
Eli didn't explicitly comment on the patch so far, but let me quote some of his
earlier comments:
> if the reader discards parts of the tree (by deleting subtrees), then
> returning the root from close() becomes even more meaningless, because it
Stefan Behnel added the comment:
Thanks, Nick. Your changes look good to me.
--
___
Python tracker
<http://bugs.python.org/issue18990>
___
___
Python-bugs-list m
Stefan Behnel added the comment:
Any comment and/or reason?
--
___
Python tracker
<http://bugs.python.org/issue19010>
___
___
Python-bugs-list mailing list
Unsub
Stefan Behnel added the comment:
Closing #18990 defines the API of the new XMLPullParser that 3.4 will ship
with, so this ticket becomes an enhancement for future versions.
--
type: behavior -> enhancement
versions: -Python 3.4
___
Python trac
Stefan Behnel added the comment:
Well, it worked before, so the current state is clearly a regression.
--
___
Python tracker
<http://bugs.python.org/issue19
Stefan Behnel added the comment:
Copying a relevant comment by Eli from
http://bugs.python.org/issue18990#msg198145 and replying inline.
"""
The way the APIs are currently defined, XMLParser and XMLPullParser are
different animals. XMLParser can be considered to only have one
Stefan Behnel added the comment:
Given that the inheritance chain has no real user impact, I can live with this
difference.
--
___
Python tracker
<http://bugs.python.org/issue19
Stefan Behnel added the comment:
Patch LGTM and seems to work well, according to your numbers.
Only minor nitpick would be that the method references could be decref-ed
earlier, but that would complicate the code a bit.
--
___
Python tracker
<h
Stefan Behnel added the comment:
Antoine, I really don't like this attitude of adding code and then saying
"well, it's there, I won't change it" when others complain about breakage.
Please undo your change that broke the ability of using (non-trivial) wrapper
script
Stefan Behnel added the comment:
Can you update the benchmark numbers to show what the difference is compared to
pure Python (and to the fastpath) now?
One more thing: the fastpath depends on .__getitem__() and friends, whereas the
fallback path depends on .get(). What if someone overrides
Stefan Behnel added the comment:
> I'm leaving you with this, if you're wanting to do anything about it
Sorry, but weren't you just asking *me* to be constructive?
I'm aware that getting this change right isn't trivial. But that doesn't mean
we should happ
Stefan Behnel added the comment:
What about this: by default, we assume all runtimes to have the same major
version as the Python runtime that executes the benchmark runner. If that's not
the case, users must override it explicitly with a command line option, say,
"--pyversions
Stefan Behnel added the comment:
I'm having trouble understanding your last comment. Are you saing that you want
the exact value to be a two digits version and therefore use separate arguments
for both Pythons (e.g. "--basever 2.7 --cmpver 3.3"), or that you want it to
a
Stefan Behnel added the comment:
Just as a quick update here: Cython has since then switched to only using
PyObject_ClearWeakRefs() and otherwise leaves the handling of the weakref slot
to CPython.
--
___
Python tracker
<http://bugs.python.
Stefan Behnel added the comment:
Here's a patch that replaces the current simplistic Python executable command
config with a dedicated PythonRuntime config class. That makes it easy to
properly pass around the program specific configuration. Part of that is the
Python executable path
Changes by Stefan Behnel :
--
components: +Benchmarks
nosy: +scoder
___
Python tracker
<http://bugs.python.org/issue19236>
___
___
Python-bugs-list mailin
801 - 900 of 1287 matches
Mail list logo