[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Georg Brandl

Georg Brandl added the comment:

That sounds good to me. Maybe without so many parentheses :)

--
nosy: +georg.brandl

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12736] Request for python casemapping functions to use full not simple casemaps per Unicode's recommendation

2016-03-10 Thread Benjamin Peterson

Benjamin Peterson added the comment:

The full case mappings do not preserve normalization form.

>>> for c in 'ΰ'.upper().lower(): print(unicodedata.name(c))
... 
GREEK SMALL LETTER UPSILON
COMBINING DIAERESIS
COMBINING ACUTE ACCENT
>>> unicodedata.normalize('NFC', 'ΰ'.upper().lower()) == 'ΰ'
True

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Antony Lee

Antony Lee added the comment:

I think mentioning calcsize is still helpful, so perhaps something like
"The buffer must contain exactly as many bytes (I think this is clearer than 
"the amount of data") as required by the format (this number can be obtained as 
`struct.calcsize(fmt)`)"?  (and likewise for "unpack_from" and "iter_unpack").

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +mark.dickinson, meador.inge

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I would remove "len(bytes) must equal " at all. len() can return a value not 
equal to the number of bytes contained in the buffer (e.g. for array('I')).

--
nosy: +martin.panter, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26506] hex() documentation: mention "%x" % int

2016-03-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is no harm if use hex(value)[2:]. It's a matter of taste.

We can mention "%x" % value for the case if the user just doesn't know about 
this alternative. The same is for value.ljust(5) and '%-5s' % value.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26537] ConfigParser has optionxform, but not sectionxform

2016-03-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26537] ConfigParser has optionxform, but not sectionxform

2016-03-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: ConfigParser has optoinxform, but not sectionxform -> ConfigParser has 
optionxform, but not sectionxform
type:  -> enhancement
versions:  -Python 2.7, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26537] ConfigParser has optoinxform, but not sectionxform

2016-03-10 Thread Gereon Kaiping

New submission from Gereon Kaiping:

configparser.ConfigParser (resp. ConfigParser.RawConfigParser for python2) has 
a optionxform function which converts the option names in a section to lower 
case by default.

A similar function for section titles would be expected (cf. 
https://github.com/lmaurits/BEASTling/issues/46#issuecomment-195131900), but it 
does not exist.

If ConfigParser called such a function (reasonably named sectionxform), which 
would default to None (or the identity function) for backward compatibility, 
that would be nice and consistent.

--
components: Library (Lib)
messages: 261543
nosy: Anaphory
priority: normal
severity: normal
status: open
title: ConfigParser has optoinxform, but not sectionxform
versions: Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26506] hex() documentation: mention "%x" % int

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

Serhiy Storchaka added the comment:
> If document alternatives for hex(), we should also document formatting
alternatives for bin(), oct(),

Ok for these two since they also add a prefix. But I don't see the point of
documenting alternatives for the other listed functions. The matter here is
the 0x prefix.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3

paul j3 added the comment:

http://stackoverflow.com/a/35144270/901925
dynamically-set-default-value-from-cfg-file-through-argparse-python

is my answer to a similar recent (Feb 2015) SO question.

I rather like the idea of using collections.ChainMap on the dictionary versions 
of the namespace and config data.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3

paul j3 added the comment:

Let's see if I understand the proposed patch

Each call to 'take_action' is replaced with a save to a 'action_with_values' 
dictionary

For a flagged (optional) it saves the 'args' and 'option_string'; for 
positionals it save 'args':

-take_action(action, args, option_string)
+action_with_values(action)['argument_strings'] = args
+action_with_values(action)['option_string'] = option_string

Then at the end of the 'consume_optional' and 'consume_positionals' loops, it 
processes all the deferred 'take_actions'

+for action, kwargs in actions_with_values.items():
+take_action(action, **kwargs)


It had previously looped through 'parser._actions' and created an entries in 
'actions_with_values' with actions and 'fallback_strings' key.

In 'take_action', if the action's 'argument_strings' key (in 
actions_with_values) is None, it uses the 'fallback_strings' instead.

--

Has this patch been tested?  That is, does it pass all the tests in 
'test_argparse.py'?

One potential failing is that the order in which 'take_action' occurs can 
change.  In the original, the order of 'take_action' depends on the order of 
occurrence in the sys.argv list.  With this change, the order depends on the 
hashing order in 'actions_with_values'.

In many cases that order does not matter.  But there's nothing, in the current 
code, to prevent order dependence.  Even if the user does not define custom 
Actions, actions like 'append' are execution order dependent.  And optionals 
may occur several times, e.g 

python prog.py -f one --foo two -f three

the namespace could have (foo='three') or (foo=['one','two','three']) depending 
the Action class.

And different arguments can save to the same 'dest'.

Deferring 'take_action' like this is too fraught with backward compatibility 
issues to consider seriously.  Parsing is complex enough as it is, without 
adding the uncertainty of this differed 'take_action'.

Other qualms:

- On the surface the process of collecting 'fallback_strings' appears to handle 
the number of arguments correctly (with '_match_argument); but I have feeling 
it could be buggy.

- What if the 'fallback' wants to provide values and objects instead of 
strings?  That's a tricky enough issue when working with the defaults.  The 
example.py had to handle 'false' in a special way.  The 'store_const' actions 
(including 'store_true' and 'store_false') will need special testing.

- how will these changes behave with subparsers?  That is a big unknown.


--

An alternative place to apply this kind of 'fallback' is at the end of 
'_parse_known_args'.  At this point the parser has access to 'see_actions' and 
'seen_non_default_actions' lists (or sets).  It uses those to test for 
'required_actions' and required mutually_exclusive_groups.

In http://bugs.python.org/issue11588 (Add "necessarily inclusive" groups to 
argparse) I propose adding a 'hook' at this point that can be used apply more 
general group tests (not just the current xor, but all the other logical 
possibilities).  This hook could look at which actions were seen (i.e. acted on 
by take_action), and raise errors if the wrong combination was seen or not 
seen.  The idea is that access to 'see_actions' is more definitive than 
checking the namespace of 'is None' values.

I can imagine a fallback operating as part of this hook, filling in value for 
required actions that were not seen.

This is similar to looking at and modifying the args namespace after parsing, 
except that it has access to the 'seen_actions' set.  By acting at this point, 
the fallback is not constrained by the action's __call__ or any of its 
parameters (nargs, type, etc).  There are pros and cons to that.

---

I've mentioned else where (including SO questions) that 'ipython' uses argparse 
along with config.  It does so by first reading config, and then populating the 
parser with arguments derived from the config.  That way the user has several 
ways of setting values - the default config, profile configs, and the 
commandline.  In practice most values come from config, and only a select few 
get changed via commandline.

argparse already as a poor-man's config file mechanism, the 
'fromfile_prefix_chars'.  This reads strings from a file and splices them into 
the 'argv' list.

   if self.fromfile_prefix_chars is not None:
arg_strings = self._read_args_from_files(arg_strings)

It's not as powerful as config or reading the environment, but it still 
provides a way of adding strings to those already given in the commandline.

In short, I think it best to exhaustively look at alternatives that don't 
require surgery to the heart of parse_args.  A feature like this can only be 
added if it has absolutely zero chance of modifying the behavior of anyone 
else's parser.

--

___
Python 

[issue26535] Minor typo in the docs for struct.unpack

2016-03-10 Thread Antony Lee

New submission from Antony Lee:

The docstring of struct.unpack currently reads

Unpack from the buffer buffer (presumably packed by pack(fmt, ...)) according 
to the format string fmt. The result is a tuple even if it contains exactly one 
item. The buffer must contain exactly the amount of data required by the format 
(len(bytes) must equal calcsize(fmt)).

It should probably read "len(buffer) must equal calcsize(fmt)".

--
assignee: docs@python
components: Documentation
messages: 261538
nosy: Antony.Lee, docs@python
priority: normal
severity: normal
status: open
title: Minor typo in the docs for struct.unpack
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3

paul j3 added the comment:

I need to study that patch more, but I don't like the fact that it operates at 
the core of the parsing (e.g. in 'take_action').  That's a dangerous place to 
add features.  Unexpected behaviors and backwards compatibility problems are 
too likely.

It would be better if the enhancement could be made to things that are already 
being subclassed, like Actions.  But I'll have to think more about alternatives.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26394] Have argparse provide ability to require a fallback value be present

2016-03-10 Thread paul j3

Changes by paul j3 :


--
nosy: +paul.j3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26533] logging.config does not allow disable_existing_loggers=True

2016-03-10 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26503] argparse with required field , not having new line separator in -help dispaly

2016-03-10 Thread paul j3

paul j3 added the comment:

The usage line formatter needs a major rewrite.  

Currently it formats usage for all the arguments as one line (two actually, 
optionals and positionals are handled separately), and then breaks it into 
'wrappable parts'.  It then compiles the lines from these parts

# break usage into wrappable parts
part_regexp = r'\(.*?\)+|\[.*?\]+|\S+'

So it's keeping things enclosed in brackets together, but allowing the 
'required' arguments to be split.

Certain characters like [] in the metavars also break this usage.

http://bugs.python.org/issue11874  

has a patch with a usage rewrite hopefully will take care of this problem.  It 
collects the formatted arguments in a list rather than a concatenated string, 
so there's no need for this buggy splitter.

--
nosy: +paul.j3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26510] [argparse] Add required argument to add_subparsers

2016-03-10 Thread paul j3

paul j3 added the comment:

This has been raised before.  I think

http://bugs.python.org/issue9253

is the correct issue.

It used to be that 'subparsers' were required.  But there was a change in how 
'required' arguments were tested, and 'subparsers' fell through the cracks.  
Now subparsers are optional (at least the parser doesn't raise an error).  The 
temporary fix is to set the 'required' attribute after creation.

I proposed that the default be 'required=True', and that we be allowed to set 
the parameter.  But that patch, like many others, has languished.

--
nosy: +paul.j3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17603] AC_LIBOBJ replacement of fileblocks

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

IMO this is a fault of the autowhatever configuration stuff, not just an 
enhancement. If configure.ac determines that there is no st_blocks field, it 
tries to link against a non-existant fileblocks.o file:

./mingw/Makefile:220:LIBOBJS=${LIBOBJDIR}fileblocks$U.o
i486-mingw32-gcc: error: Python/fileblocks.o: No such file or directory

I am not really an autoconf or whatever expert, but it seems if you use a 
lower-level bit of configure.ac code it avoids the problem; see 
avoid-fileblocks.patch.

--
components:  -Cross-Build
nosy: +martin.panter
type: enhancement -> compile error
Added file: http://bugs.python.org/file42123/avoid-fileblocks.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26534] subprocess.check_output with shell=True ignores the timeout

2016-03-10 Thread Daniel Shaulov

New submission from Daniel Shaulov:

Basically -
subprocess.check_output("ping localhost", shell=True, timeout=5)
Will hang forever.

What happens is that subprocess.run times out on communicate, sends SIGKILL *to 
the shell* and then calls communicate again without the timeout. But nothing 
actually closes the "ping" command so the second communicate will never exit.

Even if we put a timeout on the second communicate, it won't be good enough 
because that "ping" will still be "leaked".

This SO question is about the fact that kill doesn't work when shell=True, and 
might be relevant for this issue:
http://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true

As a possible fix I propose doing the following:
1. Add killpg to the Popen class.
2. Add an argument to run - "kill_group" that makes run use killpg instead of 
kill
3. Users can all:
subprocess.check_output("ping localhost", shell=True, start_new_session=True, 
kill_group=True, timeout=5)

And have it work fine. This is the best I could come up with, without breaking 
any existing behavior.

Other options to consider:
1. Not have kill_group argument and to implicitly kill by group when 
start_new_session is True (but this is not really backwards compatible).
2. Having kill_group as an argument for Popen and not run, and when kill is 
called, it will call killpg if the option was specified.

A patch is attached with my proposed solution.

--
components: Library (Lib)
files: killpg.patch
keywords: patch
messages: 261533
nosy: Daniel Shaulov, astrand
priority: normal
severity: normal
status: open
title: subprocess.check_output with shell=True ignores the timeout
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42122/killpg.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26525] Documentation of ord(c) easy to misread

2016-03-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

'' is astral character and not all systems have fonts that support it 
installed by default. It can be hard to render it in TeX.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23220] Documents input/output effects of how IDLE runs user code

2016-03-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

As for StackOverflow question, there is tkinter.ttk.Progressbar.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26521] add `extend_enum` to Enum

2016-03-10 Thread Ethan Furman

Ethan Furman added the comment:

Barry:  po-tay-to / po-tah-to   ;)

Serhiy:  The set is known and finite, just scattered over different 
expensive-to-load modules.

Decision:
Since no one is jumping up and down with anticipation over this feature, I'll 
let it stay on SO.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23220] Documents input/output effects of how IDLE runs user code

2016-03-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Part of this issue is the difference between typing a character at the 
keyboard, which produces a key event whose effect is determined by key bindings 
(some default, some added) and inserting a character into a Text widget, which 
does not produce an event (except, in some sense, \t and \n).  Whether or not a 
key event results in character insertion depends on key bindings.  The visual 
effect of inserted chars other than \t and \n is determined by the font.  (I 
believe I got the above right.) I believe some terminals treat chars coming 
over the wire the same as those typed.  I am not sure what the Win10 console is 
doing with control-x keystrokes.

>>> import sys; out=sys.stdout.write
# use direct write to avoid str(), repr() conversion of control chars
>>> out('\x03')
1  # The first char is an empty thin box in my IDLE.
>>> # type ^C
KeyboardInterrupt

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23220] Documents input/output effects of how IDLE runs user code

2016-03-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Different \r behavior is the gist of 
https://stackoverflow.com/questions/35895864/what-is-the-difference-between-cmd-and-idle-when-using-tqdm.
  The new section should have more on the different effect of control 
characters on different display devices and windows. It should also better 
differentiate between Python result, which is the string written to stdout, and 
which is nearly always the same in IDLE and console, and visual display result, 
which is  outside of Python's control.  This separation is the point of 
Serhiy's msg246602.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26525] Documentation of ord(c) easy to misread

2016-03-10 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Wouldn't '\N{SNAKE}' look more pythonic?  

>>> hex(ord(''))
'0x1f40d'

--
nosy: +belopolsky

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26533] logging.config does not allow disable_existing_loggers=True

2016-03-10 Thread Grazfather x

New submission from Grazfather x:

logging.config.FileConfig has a kwarg 'disable_existing_loggers' that defaults 
to False, but when true will allow you to load a config and not disable all 
other existing loggers.

logging.config.listen uses FileConfig, but has no option to provide this 
keyword to it, which is a problem when a logger hierarchy is build using 
logger.getLogger(__name__) (which is recommended in the documentation).

Proposal: Add kwarg 'disable_existing_loggers' to logging.config.listen which 
is passed to fileConfig.

--
components: Library (Lib)
messages: 261526
nosy: Grazfather x
priority: normal
severity: normal
status: open
title: logging.config does not allow disable_existing_loggers=True
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26495] super() does not work in nested functions, genexps, listcomps, and gives misleading exceptions

2016-03-10 Thread Eric Snow

Changes by Eric Snow :


--
nosy: +benjamin.peterson, rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26532] build fails with address sanitizer

2016-03-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is a gcc issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65873 .

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26528] NameError for built in function open when re-raising stored exception from yielded function

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

Actually I was a bit hasty in my response last night. NameError indicates that 
the “open” symbol has been deleted, not just set to None. If you add 
print(sorted(builtins.__dict__.keys())) inside __exit__() you can verify this 
is the case.

This contradicts my understanding of the finalization process (symbols being 
deleted rather than being set to None). Maybe the documentation needs fixing?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] KeyboardInterrupt while in input() not catchable on Windows 10

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

It sounds like you guys might be (re-)discovering existing bugs to do with 
KeyboardInterrupt in input on Windows:

* Issue 18597 (Py 2 & 3): Strange exception handling reading stdin
* Issue 10837 (2.7): KeyboardInterrupt deferred reading stdin
* Issue 25376 (Py 3): Truncated traceback from input()
* Issue 13673 (Py 2 & 3): General traceback truncated if interrupted

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12736] Request for python casemapping functions to use full not simple casemaps per Unicode's recommendation

2016-03-10 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12736] Request for python casemapping functions to use full not simple casemaps per Unicode's recommendation

2016-03-10 Thread SilentGhost

Changes by SilentGhost :


--
versions: +Python 3.4, Python 3.5, Python 3.6 -Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12736] Request for python casemapping functions to use full not simple casemaps per Unicode's recommendation

2016-03-10 Thread Андрей Баксаляр

Андрей Баксаляр added the comment:

Interestingly, the bug is still reproducible in version 3.5.1, but fixed in 
2.7.6.

--
versions: +Python 2.7 -Python 3.4
Added file: http://bugs.python.org/file42121/pythonbug.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26532] build fails with address sanitizer

2016-03-10 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +benjamin.peterson, haypo, serhiy.storchaka
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26532] build fails with address sanitizer

2016-03-10 Thread shakur shams Mullick

New submission from shakur shams Mullick:

After configuring with address sanitizer like this:

$ ./configure --with-address-sanitizer --disable-ipv6

build fails when:
$make

gcc -pthread -c -fsanitize=address -fno-omit-frame-pointer  -Wno-unused-result 
-Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes-Werror=declaration-after-statement   -I. -IInclude 
-I./Include-DPy_BUILD_CORE -o Objects/obmalloc.o Objects/obmalloc.c
In file included from /usr/include/features.h:364:0,
 from /usr/include/limits.h:25,
 from 
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:168,
 from 
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:7,
 from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:34,
 from Include/Python.h:11,
 from Objects/obmalloc.c:1:
Objects/obmalloc.c: In function ‘_PyObject_Realloc’:
/usr/include/x86_64-linux-gnu/bits/string3.h:50:1: error: inlining failed in 
call to always_inline ‘memcpy’: function attribute mismatch
 __NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
 ^
Objects/obmalloc.c:1668:13: error: called from here
 memcpy(bp, p, size);
 ^
Makefile:1538: recipe for target 'Objects/obmalloc.o' failed
make: *** [Objects/obmalloc.o] Error 1

--
components: Build
messages: 261521
nosy: shakur shams Mullick
priority: normal
severity: normal
status: open
title: build fails with address sanitizer
type: compile error
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] KeyboardInterrupt while in input() not catchable on Windows 10

2016-03-10 Thread Joshua Cannell

Joshua Cannell added the comment:

I can post a script if necessary, but it looks like Zach has already done so. I 
appreciate you verifying this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26520] asyncio.new_event_loop() hangs

2016-03-10 Thread Erwin Mayer

Erwin Mayer added the comment:

Thank you Guido; I am now trying to always close a loop explicitly and see if 
it fixes the issue (so far so good in the last 24h). 

I could not locate this requirement in the EventLoop documentation page 
(https://docs.python.org/3/library/asyncio-eventloop.html), however it was 
indeed mentioned in the "Develop with asyncio" documentation page 
(https://docs.python.org/3/library/asyncio-dev.html#asyncio-close-transports), 
saying that otherwise a Resource warning would be emitted (if debug mode was 
turned on).
It could be beneficial to remind the need to close the loop explicitly in the 
EventLoop page as well. I saw a lot of people posting code snippets not doing 
it. I'll check how I can submit a patch for that.

I agree with your comments on the reproductibility of my issue, I was hoping 
the stack trace could be enough to pinpoint reasons of why a socket creation 
could be hanging (and maybe diagnose a bug).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26506] hex() documentation: mention "%x" % int

2016-03-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> That's why I ran the micro-benchmark and, in fact, I was expecting 
> %-interpolation to be faster exactly because it is less flexible.

Actually %-interpolation is more flexible.

>>> '%x' % 123
'7b'
>>> '%0X' % 123
'7B'
>>> '%#x' % 123
'0x7b'
>>> '%04x' % 123
'007b'

If document alternatives for hex(), we should also document formatting 
alternatives for bin(), oct(), repr(), ascii(), str(), chr(), str.ljust(), 
str.rjust(), str.center(), str.zfill().

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12736] Request for python casemapping functions to use full not simple casemaps per Unicode's recommendation

2016-03-10 Thread Андрей Баксаляр

Андрей Баксаляр added the comment:

A same problem with the unicode case mapping is still present in the Python 
3.4.3. You can repeat the bug with this code, for instance:

'ΰ'.upper().lower() == 'ΰ'

The case swapping is strangelly leads to character replacement:

b'\xce\xb0' → b'\xcf\x85\xcc\x88\xcc\x81'

--
nosy: +Андрей Баксаляр
versions: +Python 3.4 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26506] hex() documentation: mention "%x" % int

2016-03-10 Thread Wolfgang Maier

Wolfgang Maier added the comment:

> Hum, python3 looks faster on this dummy microbenchmark yeah. Who said that 
> Python 3 is slower? :-)

If you're alluding to that seemingly endless thread over on python-list, let me 
say that it is not my motivation to start anything like that here. Sorry also 
if I sort of hijacked your documentation issue with my performance question.

I really only wondered whether there would be any argument for or against any 
of the two versions (%-interpolation, format-based) other than stylistic ones.
That's why I ran the micro-benchmark and, in fact, I was expecting 
%-interpolation to be faster exactly because it is less flexible.
What I am surprised by is not the fact that %-interpolation got faster in 
Python3, but the fact that format didn't.
I was wondering whether %-interpolation maybe takes some fast path in Python3 
that simply wasn't implemented for format. If that was the case it could have 
been rewarding to just optimize format the same way.
As I know Victor is working on performance stuff I thought I'd just ask here, 
but from your answer I gather that things are rather not so simple and that's 
ok.

> I wrote a first article to explain my work on optimization:
https://haypo.github.io/pybyteswriter.html

Thanks for the link.

> str.format(args) was also optimized, but it's still faster than str%args.

You mean slower I assume ?

> Hum, I don't recall why you started to talk about performance :-D

See above.

> Why not documenting "%x" % value *and* format(value, 'x')?

> I prefer "%x" % value. I never use format(value, ...) but sometimes I use 
> "{0:x}".format(value).

I prefer the last version, use the first sometimes, but documenting several 
ways seems reasonable.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] KeyboardInterrupt while in input() not catchable on Windows 10

2016-03-10 Thread Zachary Ware

Zachary Ware added the comment:

I can reproduce on Windows 10 with Pythons 2.7.11, 3.4.4, and 3.5.1 with the 
attached script.  Examples:

E:\>ver

Microsoft Windows [Version 10.0.10586]

E:\>py ccbug.py
2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]
Traceback (most recent call last):
  File "ccbug.py", line 12, in 
data = input()


E:\>py -3.4 ccbug.py
3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]
Traceback (most recent call last):
  File "ccbug.py", line 12, in 

E:\>py -3.5 ccbug.py
3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)]
Traceback (most recent call last):
  File "ccbug.py", line 12, in 

--
title: Keyboard Interrupts not caught when used within a class method on 
Windows 10 -> KeyboardInterrupt while in input() not catchable on Windows 10
versions: +Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42120/ccbug.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26516] Add PYTHONMALLOC env var and add support for malloc debug hooks in release mode

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

Oh, I forgot to update wmain() for Windows.

Patch 4 handles wmain() too. I added a few comments and reformatted some parts 
of the code.

--
Added file: http://bugs.python.org/file42119/pymem-4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] Keyboard Interrupts not caught when used within a class method on Windows 10

2016-03-10 Thread TJG

TJG added the comment:

If I run your code, it does what I expect: pressing Ctrl-C produces
"Interrupt", doesn't print the data returned from raw_input, and doesn't
produce a stacktrace.

I'm not on Win10 and it's entirely possible that this area of the MS CRT
has been reworked: it's a bit quirky and our use of it is fairly fragile.

I'm still not clear, though, whether we have a bug or whether it's just
that your expectation is at odds with the way in which this is intended
to work.

If you think there's a bug here, could you run the code you posted in a
console window, do what actions are needed to make it fail, and then
cut-and-paste the result here, possibly as an attached file. (Don't post
a screenshot; just use the cmd window's mark-and-copy functionality to
select the visible text).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] Keyboard Interrupts not caught when used within a class method on Windows 10

2016-03-10 Thread Joshua Cannell

Joshua Cannell added the comment:

Hi,

Thanks for the quick response.

I tried your code, it doesn't capture the keyboard interrupt, so the method 
doesn't seem to be needed. Also, the code doesn't carry on if interrupt was 
received, but instead produces the stack traceback. For example:

while True:
try:
data = raw_input()
print data
except KeyboardInterrupt:
print "Interrupt!"

Does not print "data" if a KeyboardInterrupt is received during raw_input.

Unfortunately, I can't use python 3 as my organization currently uses 2 in 
their production environment.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] Keyboard Interrupts not caught when used within a class method on Windows 10

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

Please try Python 3, I recall that we fixed bugs on input() on Windows related 
to CTRL+c.

--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

Hum, there is an issue in the patch version 2: tracemalloc_add_trace() rely on 
the assumption that the pointer is not already tracked. Since we give control 
to the traces to the user, this assumption may become wrong (if the API is 
badly used).

This issue is now fixed in the patch version 3: tracemalloc_add_trace() now 
works if the pointer is already tracked. It allows to implement a 
micro-optimization on realloc() if the new pointer is equal to the old pointer 
(memory block didn't move).

By the way, to track realloc(): _PyTraceMalloc_Untrack() must be called with 
the old pointer and _PyTraceMalloc_Track() must be called with the new pointer. 
I don't think that it's worth to add an helper function just for two calls. 
(The optimization old_ptr==new_ptr is really a micro-optimization, don't use 
tracemalloc if you care of performances, tracemalloc simply kills the 
performance ;-))

--
Added file: http://bugs.python.org/file42118/tracemalloc_track-3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] Keyboard Interrupts not caught when used within a class method on Windows 10

2016-03-10 Thread TJG

TJG added the comment:

I don't have Win10 to test with, but can you confirm that the method is
necessary for the code to fail? IOW does this fail equally?

while True:
try: raw_input()
except KeyboardInterrupt: print "Interrupt!"

Also, do I assume that the code simply carries on regardless without
reaching the exception handler? Or does something else happen?

--
nosy: +tjguk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26531] Keyboard Interrupts not caught when used within a class method on Windows 10

2016-03-10 Thread Joshua Cannell

New submission from Joshua Cannell:

There seems to be an issue capturing keyboard interrupts on Windows 10 when 
using raw_input() inside of a class method w/python 2.7.x.

So far I have tested this on:
2.7.11 x86 on Windows 10 x64 - Does not capture (Traceback)
2.7.11 x64 on Windows 10 x64 - Does not capture (Traceback)
2.7.11 x86 on Windows XP - Does capture

So far I've only tested 2.7.11, so I don't know which other version may or may 
not be affected. The proof of concept code is attached.

If there is anything else I can provide to help, please let me know. I'm not 
accustomed to posting bugs here so I apologize if I've missed something.

--
components: Windows
files: keyint_poc.py
messages: 261508
nosy: jecanne, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Keyboard Interrupts not caught when used within a class method on 
Windows 10
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file42117/keyint_poc.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

Antoine Pitrou:
> This may indeed be useful but:
> - those functions should be no-ops when tracing isn't enabled (so as to be as 
> fast as possible)

Done

> - you should take the GIL if necessary (but only if tracing is enabled, of 
> course)

Ok, done.

The new patch has a safer API:

* _PyTraceMalloc_Track() can be called twice with the same pointer: the old 
trace is removed, a new trace is added
* _PyTraceMalloc_Track() ensures that the GIL is hold
* _PyTraceMalloc_Track() & _PyTraceMalloc_Untrack() do nothing if tracemalloc 
is disabled

I also added unit tests.

--
Added file: http://bugs.python.org/file42116/tracemalloc_track-2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

This may indeed be useful but:
- those functions should be no-ops when tracing isn't enabled (so as to be as 
fast as possible)
- you should take the GIL if necessary (but only if tracing is enabled, of 
course)

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26507] Use highest pickle protocol in multiprocessing

2016-03-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Agreed with Davin.

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26525] Documentation of ord(c) easy to misread

2016-03-10 Thread Georg Brandl

Georg Brandl added the comment:

Sure!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26415] Fragmentation of the heap memory in the Python parser

2016-03-10 Thread A. Skrobov

A. Skrobov added the comment:

I've now tried it with "perf.py -r -m", and the memory savings are as follows:

### 2to3 ###
Mem max: 45976.000 -> 47440.000: 1.0318x larger

### chameleon_v2 ###
Mem max: 436968.000 -> 401088.000: 1.0895x smaller

### django_v3 ###
Mem max: 23808.000 -> 22584.000: 1.0542x smaller

### fastpickle ###
Mem max: 10768.000 -> 9248.000: 1.1644x smaller

### fastunpickle ###
Mem max: 10988.000 -> 9328.000: 1.1780x smaller

### json_dump_v2 ###
Mem max: 10892.000 -> 10612.000: 1.0264x smaller

### json_load ###
Mem max: 11012.000 -> 9908.000: 1.1114x smaller

### nbody ###
Mem max: 8696.000 -> 7944.000: 1.0947x smaller

### regex_v8 ###
Mem max: 12504.000 -> 9432.000: 1.3257x smaller

### tornado_http ###
Mem max: 27636.000 -> 27608.000: 1.0010x smaller


So, on these benchmarks, the saving is not threefold, of course; but still 
quite substantial (up to 30%).


The run time difference, on these benchmarks, is between "1.04x slower" and 
"1.06x faster", for reasons beyond my understanding (variability of background 
load, possibly?)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26529] urllib.request: ftplib's cwd() can do harm

2016-03-10 Thread Vadim Markovtsev

Changes by Vadim Markovtsev :


--
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

Patch without test.

I chose to require the GIL to be held for efficiency. IMHO the common case is 
more than the GIL is held.

Example to call the function if the GIL is not held:

int res;
PyGILState_STATE gil_state;
gil_state = PyGILState_Ensure();
res = _PyTraceMalloc_Track(ptr, size);
PyGILState_Release(gil_state);
return res;

See also my numpy pull request on PyMem_Malloc() called without the GIL being 
held:
https://github.com/numpy/numpy/pull/7404

--
keywords: +patch
Added file: http://bugs.python.org/file42115/tracemalloc_track.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26528] NameError for built in function open when re-raising stored exception from yielded function

2016-03-10 Thread reidfaiv

reidfaiv added the comment:

Indeed, explicitly closing generator helps, following works:

def run(**kwargs):
g = event_gen(**kwargs)
r = next(g)
g.close()
r()

Thanks!

Do you want to keep this issue open for investigation?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-10 Thread STINNER Victor

New submission from STINNER Victor:

The API of Python memory allocators was extended for numpy: calloc() was added 
(issue #21233). It looks like it's not enough because allocations with an 
alignment is also required for vector operations (SIMD). For Python, there is 
the issue #18835 but the benefit for Python code is unclear or negligible.

Instead of extending the API each time, it would be simpler to add an API to 
allow third party memory allocators to track/untrack memory in tracemalloc. I 
guess that the API should make the assumption that the GIL is not hold and so 
try to acquire the GIL (if it's not already hold).

Related numpy issue: https://github.com/numpy/numpy/issues/4663

See also: 
https://mail.scipy.org/pipermail/numpy-discussion/2015-January/072068.html

--
messages: 261501
nosy: haypo, njs
priority: normal
severity: normal
status: open
title: tracemalloc: add C API to manually track/untrack memory allocations
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26512] Vocabulary: Using "integral" in library/stdtypes.html

2016-03-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26512] Vocabulary: Using "integral" in library/stdtypes.html

2016-03-10 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26528] NameError for built in function open when re-raising stored exception from yielded function

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

What is probably happening here is how garbage collection works at the 
interpreter exit. It is sort of mentioned in the warning at 
.

The variable g is an iterator for event_gen(), and it is still “alive” when the 
exception is raised. The exception contains a reference to the traceback and 
all the local variables, including g. So the context manager in the generator 
cannot exit until g is deleted [or g.close() is called].

In the “volatile exception” case, I guess it is easy for the interpreter to 
release the exception traceback, including the g iterator that it references, 
straight after it has reported the traceback.

But when you store an exception that you catch in a local variable, you create 
a reference loop (something like ee.__traceback__.tb_frame.f_locals["ee"] is 
ee). So it is not so easy to release the references, and by the time the 
garbage collector runs, I guess it has already set builtin names like “open” 
(global variable of the “builtins” module) to None.

If you need a generator to clean up, you should probably close the generator 
before exiting the function rather than relying on garbage collection. 
Unfortunately there is no mechanism like ResourceWarning to indicate this 
problem with generators.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26529] urllib.request: ftplib's cwd() can do harm

2016-03-10 Thread Vadim Markovtsev

New submission from Vadim Markovtsev:

urllib/request.py, near line 2345

# Set transfer mode to ASCII!
self.ftp.voidcmd('TYPE A')
# Try a directory listing. Verify that directory exists.
if file:
pwd = self.ftp.pwd()
try:
try:
self.ftp.cwd(file)
except ftplib.error_perm as reason:
raise URLError('ftp error: %r' % reason) from reason
finally:
self.ftp.cwd(pwd)
cmd = 'LIST ' + file
else:
cmd = 'LIST'
conn, retrlen = self.ftp.ntransfercmd(cmd)

and near line 2314:

def init(self):
import ftplib
self.busy = 0
self.ftp = ftplib.FTP()
self.ftp.connect(self.host, self.port, self.timeout)
self.ftp.login(self.user, self.passwd)
_target = '/'.join(self.dirs)
self.ftp.cwd(_target)

The fact is, one can download a file from FTP without accessing the listing of 
it's parent directory. Example: 
ftp://ftp.apnic.net/apnic/whois-data/APNIC/split/apnic.db.inetnum.gz (African 
whois db). So these cwd() calls prevent from successfully downloading the file. 
If the corresponding blocks are commented out, the file is downloaded OK.

I am not sure how to fix this, rather than totally remove cwd() stuff.

--
components: Library (Lib)
messages: 261498
nosy: Vadim Markovtsev
priority: normal
severity: normal
status: open
title: urllib.request: ftplib's cwd() can do harm
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26528] NameError for built in function open when re-raising stored exception from yielded function

2016-03-10 Thread reidfaiv

New submission from reidfaiv:

Builtin open() gets NameError) in context manager __exit__ in case:
* context manager yielding records
* we return another generator when consuming these and
* second generator raises, catches, stores and re-raises an excption


Reduced down code looks like this:
---
#!/usr/bin/env python
# -*- coding: utf-8 -*-


# context manager "query" (open in init, yield rows and close on exit)
class _query():
def __init__(self, **kwargs):
pass

def __enter__(self):
return [1, 2, 3]

def __exit__(self, type_, value, tb):
print('__exit__')   # print() is also built-in, but works
f = open('test.log', 'wt')  # <-- NameError: name 'open' is not defined
f.close()


# this works fine
def a():
try:
raise Exception('volatile exception')
except Exception as e:
raise e


# this does not work
def b():
try:
raise Exception('stored exception')
except Exception as e:
ee = e  # <-- storing exception and then
raise ee# <-- re-raising stored exception triggers the issue


def event_gen(**kwargs):
with _query() as cursor:
for _ in cursor:
yield b # <--- does not work
# yield a   # <--- works fine


def run(**kwargs):
g = event_gen(**kwargs)
r = next(g)
r()
# This also works
# for r in event_gen(**kwargs):
# r()

if __name__ == '__main__':
run()


---
>python.exe gen_err.py
Traceback (most recent call last):
  File "gen_err.py", line 52, in 
run()
  File "gen_err.py", line 46, in run
r()
  File "gen_err.py", line 33, in b
raise ee# <-- re-raising stored exception triggers the issue
  File "gen_err.py", line 30, in b
raise Exception('stored exception')
Exception: stored exception
__exit__
Exception ignored in: 
Traceback (most recent call last):
  File "gen_err.py", line 39, in event_gen
  File "gen_err.py", line 15, in __exit__
NameError: name 'open' is not defined


This happens with Python 3.4+
Works with earlier versions as expected.

If exception re-raised immediately, works fine.
If outermost generator is consumed in for loop, works fine.

--
components: Interpreter Core
files: gen_err.py
messages: 261497
nosy: reidfaiv
priority: normal
severity: normal
status: open
title: NameError for built in function open when re-raising stored exception 
from yielded function
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file42114/gen_err.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17597] mingw: Allow Objects/exceptions.c to include "errmap.h"

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

Yes it makes more sense to me to move the file to a common directory. That 
should avoid any potential conflict with pyconfig.h. What did you mean by a 
platform-specific filename?

Here is a patch to move the file. I have not tested regenerating it however, so 
it would be good to get some feedback on that. I don’t have a Windows etc setup 
to check if I have broken anything.

--
components: +Windows -Cross-Build
nosy: +martin.panter, paul.moore, steve.dower, tim.golden, zach.ware
stage:  -> patch review
title: mingw: add $srcdir/PC to CPPFLAGS -> mingw: Allow Objects/exceptions.c 
to include "errmap.h"
Added file: http://bugs.python.org/file42113/move-errmap.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15693] expose glossary link on hover

2016-03-10 Thread Chris Jerdonek

Chris Jerdonek added the comment:

It looks like the issue I previously filed on the Sphinx tracker was migrated 
here: https://github.com/sphinx-doc/sphinx/issues/996 . But the patch I 
submitted seems to have been dropped.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26506] hex() documentation: mention "%x" % int

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

> I regulary see Python code using hex(value)[2:]

In fact, it's even worse, I also saw Python 2 code stripping trailing "L", 
since hex(long) adds a L suffix...

$ python2
Python 2.7.10 (default, Sep  8 2015, 17:20:17) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
>>> hex(123L)
'0x7bL'
>>> "%x" % 123L
'7b'
>>> format(123L, "x")
'7b'
>>> "%#x" % 123L
'0x7b'
>>> format(123L, "#x")
'0x7b'

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26525] Documentation of ord(c) easy to misread

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

I suggest to use the EURO SIGN € (U+20ac).

--
keywords: +easy
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26527] CGI library - Using unicode in header fields

2016-03-10 Thread Olivier Le Moign

Olivier Le Moign added the comment:

I guess this is fixed by https://pypi.python.org/pypi/rfc6266. Could have 
looked better, sorry.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26527] CGI library - Using unicode in header fields

2016-03-10 Thread Olivier Le Moign

New submission from Olivier Le Moign:

According to RFC5987 (http://tools.ietf.org/html/rfc5987), it's possible to use 
other encoding than ASCII in header fields. 
Specifically in the CGI library, posting files with non-ASCII characters will 
lead the header to be (for example) filename*=utf-8"x" which is not 
recognised:

l 513

if 'filename' in pdict:
self.filename = pdict['filename']
self._binary_file = self.filename is not None 

The file will thus be treated as a string.
The correction isn't too big but being a total newbie, I'm a bit scared to 
suggest a patch.

--
components: Unicode
messages: 261491
nosy: ezio.melotti, haypo, olemoign
priority: normal
severity: normal
status: open
title: CGI library - Using unicode in header fields
type: behavior
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23857] Make default HTTPS certificate verification setting configurable

2016-03-10 Thread Nick Coghlan

Nick Coghlan added the comment:

The attached patch adds documentation (to the ssl module docs, the environment 
variable descriptions and the 2.7 What's New) and also fixes the 
PYTHONHTTPSVERIFY tests to use a subprocess so they can still run under -E.

Assuming the docs pass muster, then the only bit missing should be the NEWS 
entry.

--
stage:  -> commit review
Added file: http://bugs.python.org/file42112/pep493_with_docs.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17596] mingw: add wincrypt.h in Python/random.c

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

Yes I would tend to think including  would be harmless on Windows, 
but I don’t have a native Windows to try it out on. Here is a proposed patch 
anyway. It would be good for someone to be able to confirm it doesn’t break the 
normal Windows build.

--
components: +Windows
nosy: +Alex.Willmer, martin.panter, paul.moore, steve.dower, tim.golden, 
zach.ware
stage:  -> patch review
versions: +Python 3.6 -Python 3.4
Added file: http://bugs.python.org/file42111/MINGW-wincrypt.v3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26249] Change PyMem_Malloc to use pymalloc allocator

2016-03-10 Thread STINNER Victor

STINNER Victor added the comment:

> Does the API doc say anything about the GIL, for example?

I modified Python to add assert(PyGILState_Check()); in PyMem_Malloc() and 
other functions.

Sadly, I found a bug in Numpy: Numpy releases the GIL for performance but call 
PyMem_Malloc() with the GIL released. I proposed a fix:
https://github.com/numpy/numpy/pull/7404

I guess that the fix is obvious and will be quickly merged, but it means that 
other libraries may have the issue.

Using the issue #26516 (PYTHONMALLOC=debug), we can check PyGILState_Check() at 
runtime, but there is currently an issue related to sub-interpreters. The 
assertion fails in support.run_in_subinterp(), function used by test_threading 
and test_capi for example.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17590] mingw: translate gcc internal defines to python platform specific defines

2016-03-10 Thread Martin Panter

Martin Panter added the comment:

What’s the point of allowing each macro to already be defined? I understand 
they may also be defined by PC/pyconfig.h, but is that possible if __MINGW32__ 
is defined?

Is the __MINGW32__ condition needed at all? Maybe we can just blindly rely on 
the _WIN32 etc macros. Perhaps the PC/pyconfig.h definitions could be removed 
in favour of the ones in "pyport.h"?

--
components: +Windows
nosy: +Alex.Willmer, martin.panter, paul.moore, steve.dower, tim.golden, 
zach.ware
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26526] In parsemodule.c, replace over 2KLOC of hand-crafted validation code, with a DFA

2016-03-10 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26526] In parsermodule.c, replace over 2KLOC of hand-crafted validation code, with a DFA

2016-03-10 Thread STINNER Victor

Changes by STINNER Victor :


--
title: In parsemodule.c, replace over 2KLOC of hand-crafted validation code, 
with a DFA -> In parsermodule.c, replace over 2KLOC of hand-crafted validation 
code, with a DFA

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26526] In parsemodule.c, replace over 2KLOC of hand-crafted validation code, with a DFA

2016-03-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26525] Documentation of ord(c) easy to misread

2016-03-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +georg.brandl

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26526] In parsemodule.c, replace over 2KLOC of hand-crafted validation code, with a DFA

2016-03-10 Thread A. Skrobov

New submission from A. Skrobov:

Updating Modules/parsermodule.c for every change in grammar and/or parser is a 
maintenance burden, listed as such at 
https://docs.python.org/devguide/grammar.html

The attached patch lets the validation code use the auto-generated DFA 
structures, thus ensuring it stays up to date with the grammar. It also trims 
the code by over 2KLOC.

--
components: Extension Modules
files: patch
messages: 261486
nosy: A. Skrobov, fdrake
priority: normal
severity: normal
status: open
title: In parsemodule.c, replace over 2KLOC of hand-crafted validation code, 
with a DFA
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file42110/patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26525] Documentation of ord(c) easy to misread

2016-03-10 Thread gladman

New submission from gladman:

It is very easy to misread the greek 'nu' used in the ord(c) documentation as 
ord('v') (i.e. an alphabetic 'v').  This can lead the reader to draw a wrong 
conclusion about the behaviour of the function. 

Would it not be better if this example used a greek letter that is less easy to 
misread in this way?  Or, perhaps, add extra text indicating that the greek 
letter 'nu' is being referenced?

--
assignee: docs@python
components: Documentation
messages: 261485
nosy: docs@python, gladman
priority: normal
severity: normal
status: open
title: Documentation of ord(c) easy to misread
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com