[issue32872] backport of #32305 causes regressions in various packages

2018-03-27 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6005

___
Python tracker 

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



[issue32872] backport of #32305 causes regressions in various packages

2018-03-27 Thread Ned Deily

Ned Deily  added the comment:


New changeset e52ac045972a4f75d7f52e4ee0d6de128259134d by Ned Deily in branch 
'master':
bpo-32872: Avoid regrtest compatibility issue with namespace packages. (GH-6276)
https://github.com/python/cpython/commit/e52ac045972a4f75d7f52e4ee0d6de128259134d


--

___
Python tracker 

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



[issue32872] backport of #32305 causes regressions in various packages

2018-03-27 Thread miss-islington

Change by miss-islington :


--
pull_requests: +6004

___
Python tracker 

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



[issue33142] Fatal Python error: Py_Initialize: Unable to get the locale encoding on Debian/Python 3.6.4 source build

2018-03-27 Thread Ned Deily

Ned Deily  added the comment:

Since python3.6 is regularly built with various Debian releases, this seems 
unlikely to be a problem in Python itself.  Suggest you verify that no venv or 
virtualenv is in use or that PYTHON* environment variables are set or that no 
modifications provided by Debian are the cause.  If you can reproduce with a 
stock Python 3.6.4 (3.6.5 shortly) tarball from python.org, please feel free to 
reopen and show the exact steps used to build, i.e. tar, configure, and make 
commands.

--
nosy: +ned.deily
resolution:  -> works for me
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



Re: please test the new PyPI (now in beta)

2018-03-27 Thread dieter
Tim Golden  writes:
> ...
> In either case, talking about it
> here seems fruitless.

Someone asked for feedback here. At least he should look for it here.

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32872] backport of #32305 causes regressions in various packages

2018-03-27 Thread Ned Deily

Change by Ned Deily :


--
pull_requests: +6003

___
Python tracker 

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



Re: Pep8 for long pattern

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 9:37:14 PM UTC-5, Dan Stromberg wrote:
> I can easily get 132+ columns of a font large enough for my
> 52 year old eyes on a 15" laptop.

Well, if you're comfortable with the long lines, fine. But
be aware that long lines are poo-pooed in most professional
enviroments.

> 80 is actually a bit defeatist, because it discourages
> developers from using more descriptive identifiers.

I'm a big fan of self-documenting code. But sometimes i have
to remind myself that really long names make the code harder
to read. The wise find a nice balance between readability
and self-documenting. And unless you're a masochist, don't
look to Microsoft for inspiration!

Another reason for 80 char limit is to prevent deeply nested
blocks. At the PEP8 recommended four-space-indention, three
blocks is about all you can get. And that's good enough for
me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Chris Angelico
On Wed, Mar 28, 2018 at 1:22 PM, Rick Johnson
 wrote:
> On Tuesday, March 27, 2018 at 6:55:23 PM UTC-5, Steven D'Aprano wrote:
>> On Tue, 27 Mar 2018 09:28:34 -0700, Rick Johnson wrote:
> [...]
>> > Since when did utilizing a method to request a specific
>> > value become some sort of magic?
>>
>> Since it requires a special method that has super powers no
>> method you can write yourself can do.
>
> That's hilarious. I guess you never called __init__? LOL!

Ah yes, argument by ridicule. An excellent way to cover over the fact
that you have not a shred of truly viable argument to bring out.

Last I checked, __init__ was just like any other dunder method: a
perfectly ordinary method that happens to be called by someone else. A
callback method, if you will.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pep8 for long pattern

2018-03-27 Thread Dan Stromberg
On Tue, Mar 27, 2018 at 4:37 PM, Rick Johnson
 wrote:
> On Tuesday, March 27, 2018 at 4:02:37 PM UTC-5, Dan Stromberg wrote:
>> On Tue, Mar 27, 2018 at 8:18 AM, Michael Torrie  wrote:
>> > But when it's exactly what you need, why do you need to
>> > shoehorn the expression into 79 characters?  Seems
>> > pointless in a case like this. PEP8 is a guideline, not an
>> > absolute rule.  It's okay to bend it a bit in cases like
>> > this.
>>
>> I think PEP8 specifying a max of 80 columns is very silly.
>> Even an old VT220 terminal could do 132 columns.
>
> And just think how many columns you could do with 1pt font!
> And while i admit i enjoy coding with my nose pressed
> against the monitor as much as the next "guyal"[1], just uh,
> be sure to keep a good optometrist on retainer, eh pal?

I realize you're just trying to be a pest, but some folks will take
your words seriously.

I can easily get 132+ columns of a font large enough for my 52 year
old eyes on a 15" laptop.

>> My understanding is that PEP8 requires 80 columns because a
>> tiny, tiny, tiny minority of Python developers wanted to be
>> able to put 3 editors next to each other horizontally,
>> without wrapping.
>
> Stacking horizontal windows three deep is all the rage, but
> the reason has more to do with easy reading. Long lines are
> difficult to read. And when your eyes do a linefeed at the
> end of a 200 character long line, there's no guarantee
> you'll end up starting on the next line. Sometimes you'll
> find yourself three lines down, while others, back at the
> start of the same line. And that's annoying.

Again, you're just trying to be a pest, but no one is asking for
10,000,000 columns.  120 or 132 would be good.

80 is actually a bit defeatist, because it discourages developers from
using more descriptive identifiers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 6:55:23 PM UTC-5, Steven D'Aprano wrote:
> On Tue, 27 Mar 2018 09:28:34 -0700, Rick Johnson wrote:
[...]
> > Since when did utilizing a method to request a specific
> > value become some sort of magic?
>
> Since it requires a special method that has super powers no
> method you can write yourself can do.

That's hilarious. I guess you never called __init__? LOL!

> Can you write a pure-Ruby method that does the same thing
> as Object.method, using only standard, public parts of the
> Ruby API? No special debugger hooks or "subject to change
> without warning" internal APIs or other private
> implementation details.

I'm not your personal tutor, Steven. And i'm not about to
waste one second of my time writing a solution to a non-
problem. Ruby already provides a well-known mechanism to
retrieve the method object. If you seek assistance, why
don't you go over the Ruby-list and ask them for help. I'm
sure they'd be very eager to help after hearing all the nice
things you've said about Ruby.

> > Even though i prefer Python's way better, the implicit
> > return of Python function references is far more "magical"
> > than making an explicit call to a method will ever be.
>
> Let's say you have an object, lassie = Dog(). How do you
> get access to her tail? Do you use dot syntax:
>
> lassie.tail

I dunno, because you failed to provide a class definition
for `Dog`, so i have nothing to go on save this horrid
explanation of yours. It'd be like me asking you to list the
contents of my refrigerator. Listen, post a code sample and
then i'll comment on it. Until then, don't expect me to read
your mind.

> [snip: more questions about some mysterious Dog class
> (probably stored at Area 51!)]
>
> Ruby attributes are always private.

Indeed. Unlike Python, Ruby is a pure OO language, and thus,
demands that public attributes must be explicitly made
public. Think of Ruby as existing somewhere between Python
and Java. Ruby tries to be as pure about OOP as it can
without becoming as onerous as Java. So yeah, you can safely
assume that Python and Ruby are not the same language
(surprising, i know!)

> You must write accessor getter and setter methods if you
> want to access them from outside the instance or class.

Yes. Unlike Python, Ruby doesn't believe in the philosophy
of "consenting adults" (where privatization of attributes
and methods is done using something as ridiculously brittle
as leading underscores [insert laugh track here]). And Ruby
sure as heck does not promote the utterly annoying Python
misfeature otherwise known as "name mangling".

Which reminds me!!!

So you think Ruby is the _only_ language that has
misfeatures? Well, feast your eyes on this Python
perversion!

>>> class Fu(object):
def bar1(self):
pass
def _bar2(self):
pass
def __bar3(self):
pass
>>> fu = Fu()
>>> [name for name in dir(fu) if 'bar' in name]
['_Fu__bar3', '_bar2', 'bar1']

What happened to the method named "__bar3"?

Where did it go?

"Hey Python, I want my symbol back!"

Tip: Better go check Area 51, cause i assure you, Steven,
you won't find that symbol anywhere in Python. It's gone
dude! Off in another parallel universe. Probably hangin'
with the Squaches and eatin' beef jerky, for all we know.

And to think! During this entire thread you have gone out of
your way to call Ruby inconsistent and accuse her of
returning surprising results... well then... tell us Mr.
D'Aprano, how does the crow taste? Hmm?

> But once you have those accessors, you can use lassie.tail
> to access the member (attribute) tail, and lassie.bark to
> *call* the method. There is no member "bark" because
> methods aren't values.

Care to provide some code that will prove your point? Or are
we condemned to suffer more of these horrid explanations of
yours?

PS: If you need help writing the Dog class, send me a PM.
And if you're nice, maybe i'll help.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33161] Refactor of pathlib's _WindowsBehavior.gethomedir

2018-03-27 Thread Ekin Dursun

Change by Ekin Dursun :


--
keywords: +patch
pull_requests: +6002
stage:  -> patch review

___
Python tracker 

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



[issue33161] Refactor of pathlib's _WindowsBehavior.gethomedir

2018-03-27 Thread Ekin Dursun

New submission from Ekin Dursun :

At line 245, default value for drv is provided with KeyError handling, but it 
is better to use dict's get method.

--
components: Library (Lib), Windows
messages: 314562
nosy: onlined, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Refactor of pathlib's _WindowsBehavior.gethomedir
type: enhancement
versions: Python 3.8

___
Python tracker 

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



[issue24132] Direct sub-classing of pathlib.Path

2018-03-27 Thread qb-cea

qb-cea  added the comment:

Hi all,

I made a pull request proposing a fix for this issue. There is still quite a 
lot to be done:
 - I exposed some variables (and probably methods too) that used to be hidden;
 - I did not update the documentation;
 - I did not add a proper test.

I will try to fix those by the end of the week.

The patch mainly consists of two things:
 - having Path (resp. PurePath) be a variable pointing at either 
(Pure)PosixPath or (Pure)WindowsPath, depending on the platform (like Kevin 
Norris suggested);
 - introducing two new abstract classes _PurePath and ConcretePath from which 
PurePosixPath, PureWindowsPath and PosixPath, WindowsPath classes inherit;
 - removing the _Flavor classes, and redistributing their method to 
platform-specific classes.

Ideally I would like _PurePath to become a public class, but I could not come 
up with a proper name. Any feedback is more than welcome =]

--

___
Python tracker 

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



Re: Welcome to the "Python-list" mailing list

2018-03-27 Thread Terry Reedy

On 3/27/2018 11:06 AM, nadir musallam wrote:


I have tried installing Python3.6.4 on my computer as I am eager to begin a


What exactly did you do?

new career in data analytics. However I am running in to some problems when attempting to set up the software. I have downloaded Dev C++ software as per 


I don't know what Dev C++ software you installed.  Visual Studio C++? 
You do not need anything other than the python.org installer to install 
and run Python.



your recommendation earlier but still getting the same error when trying to 
launch the program.


The log file shows no errors.  What did you actually do and what error 
did you see.  Either copy and paste or copy by hand.



Your assistance would be very much appreciated. I hope this time I followed the 
proper instructions for the emailing list as it is not my intention to offend 
anyone.


You post made it to python-list, where I read it.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Steven D'Aprano
On Tue, 27 Mar 2018 09:28:34 -0700, Rick Johnson wrote:
> On Tuesday, March 27, 2018 at 8:46:54 AM UTC-5, Chris Angelico wrote:
[...]
> > Cool, so Greg was right: you can't get a reference to a method or
> > function. You need magic to simulate it.
>
> Since when did utilizing a method to request a specific value become
> some sort of magic?

Since it requires a special method that has super powers no method you 
can write yourself can do.

Can you write a pure-Ruby method that does the same thing as 
Object.method, using only standard, public parts of the Ruby API? No 
special debugger hooks or "subject to change without warning" internal 
APIs or other private implementation details.

I don't believe you can.

If you can emulate Object.method, without calling Object.method either 
directly or indirectly, then it is not magic.

But if you can't, then it relies on private, esoteric knowledge of the 
Ruby internals not available to anyone else. In other words, magic.



[...]
> Even though i prefer Python's way better, the implicit return of Python
> function references is far more "magical" than making an explicit call
> to a method will ever be.

Let's say you have an object, lassie = Dog(). How do you get access to 
her tail? Do you use dot syntax:

lassie.tail

or do you call some sort of special "attribute access method"?

lassie.attribute("tail")


Of course you use the first. How is dot attribute syntax "implicit"? The 
dot for attribute access is right there, as is the name of the attribute.

None of this changes one iota if we write `lassie.bark` instead of 
`lassie.tail`. There's nothing "implicit" about it, it is as explicit as 
you can possibly get: use the dot attribute access (pseudo)operator to 
get a reference to the attribute, regardless of whether that attribute is 
a tail or a method.

The difference with Ruby is that they treat methods as a distinct kind of 
thing to other members, even though they use the same syntax (dot) for 
both. Yay for inconsistency!

Ruby attributes are always private. You must write accessor getter and 
setter methods if you want to access them from outside the instance or 
class. But once you have those accessors, you can use lassie.tail to 
access the member (attribute) tail, and lassie.bark to *call* the method. 
There is no member "bark" because methods aren't values.

That means to get access to a first-class value of the bark method, you 
need a special function, Object.method, which uses magic to wrap the 
method in an ordinary Ruby object. That's not needed in Python, because 
methods already are ordinary Python objects.



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pep8 for long pattern

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 4:02:37 PM UTC-5, Dan Stromberg wrote:
> On Tue, Mar 27, 2018 at 8:18 AM, Michael Torrie  wrote:
> > But when it's exactly what you need, why do you need to
> > shoehorn the expression into 79 characters?  Seems
> > pointless in a case like this. PEP8 is a guideline, not an
> > absolute rule.  It's okay to bend it a bit in cases like
> > this.
> 
> I think PEP8 specifying a max of 80 columns is very silly.
> Even an old VT220 terminal could do 132 columns.

And just think how many columns you could do with 1pt font!
And while i admit i enjoy coding with my nose pressed
against the monitor as much as the next "guyal"[1], just uh,
be sure to keep a good optometrist on retainer, eh pal?

> My understanding is that PEP8 requires 80 columns because a
> tiny, tiny, tiny minority of Python developers wanted to be
> able to put 3 editors next to each other horizontally,
> without wrapping.

Stacking horizontal windows three deep is all the rage, but
the reason has more to do with easy reading. Long lines are
difficult to read. And when your eyes do a linefeed at the
end of a 200 character long line, there's no guarantee
you'll end up starting on the next line. Sometimes you'll
find yourself three lines down, while others, back at the
start of the same line. And that's annoying.

> I like to check my code with pycodestyle, but I always
> override that dang 80 column requirement.

Certainly your decision. But please do try to maintain as
much of PEP8 as you can tolerate. Most of it (~75%) is
really good advice.

[1] "guy" and/or "gal" = "guyal"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 4:47:05 PM UTC-5, Gregory Ewing wrote:
> Rick Johnson wrote:
> > rb> Object.method("print_name").call("Meathead")
>
> Yes, but the point is that you have to have to use a different
> syntax to call it. This is like having to say
>
> f.__call__(arg)
>
> in Python instead of just
>
> f(arg)

You _can_ call a Ruby func/method directly by name, and i've
already demonstrated that fact. For example, the following is
perfectly legit (although untested):

def f(arg)
nil
end
f("arg")

And here is the equivalent code in Python (notice the
similarities):

def f(arg):
pass
f("arg")

The only difference is when you want to make a call from a
_reference_, which, as you and i well know, is not the most
common way func/meths are called (these are rare).

Here is Ruby 1.9:

ref = Object.method("f")
ref.call("arg")

And the Python equivalent:

ref = f
ref("arg")

NOTE: Of course, the "Python equivalent" assumes `f` is in
the current module space, whereas in Ruby, Object is
available _everywhere_.

As you can see, there is nothing "magical" about the Ruby
code. Sure, one could claim it is more onerous (and i would
agree). But to claim it is "magic" (as Chris did) is absurd.

PS: I must stress again that i am using Ruby version 1.9 and
have been for many years. I must also stress there have been
many changes in the Ruby language since 1.9 and i have not
kept up with them. So, it may be possible to do `ref("arg")`
in the newer versions. The point is, before anyone accuses
Ruby of not doing X, Y or Z -- they really should go read
the docs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Welcome to the "Python-list" mailing list

2018-03-27 Thread nadir musallam
Dear All,

Kind reminder on the below please, if there is a separate mailing list for 
installation problems I’d appreciate if you’d let me know.

Warm regards,

Nadir

Sent from my iPhone

On Mar 26, 2018, at 8:40 PM, nadir musallam 
> wrote:


Dear All,


I have tried installing Python3.6.4 on my computer as I am eager to begin a new 
career in data analytics. However I am running in to some problems when 
attempting to set up the software. I have downloaded Dev C++ software as per 
your recommendation earlier but still getting the same error when trying to 
launch the program. Your assistance would be very much appreciated. I hope this 
time I followed the proper instructions for the emailing list as it is not my 
intention to offend anyone.

Below is the updated log file for your reference:


[1D14:0FEC][2018-03-26T09:09:13]i001: Burn v3.10.3.3007, Windows v10.0 (Build 
16299: Service Pack 0), path: 
C:\Users\DELL\AppData\Local\Temp\{38A48442-951B-485A-BF38-8B6263D4F87D}\.cr\python-3.6.4-amd64-webinstall.exe
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'ActionLikeInstalling' to value 'Installing'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'ActionLikeInstallation' to value 'Setup'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'ShortVersion' to value '3.6'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'ShortVersionNoDot' to value '36'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 'WinVer' to 
value '3.6'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'WinVerNoDot' to value '36'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'InstallAllUsers' to value '0'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'InstallLauncherAllUsers' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 'TargetDir' 
to value ''
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'DefaultAllUsersTargetDir' to value '[ProgramFiles64Folder]Python[WinVerNoDot]'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'TargetPlatform' to value 'x64'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'DefaultJustForMeTargetDir' to value 
'[LocalAppDataFolder]Programs\Python\Python[WinVerNoDot]'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'OptionalFeaturesRegistryKey' to value 
'Software\Python\PythonCore\[WinVer]\InstalledFeatures'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'TargetDirRegistryKey' to value 
'Software\Python\PythonCore\[WinVer]\InstallPath'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'DefaultCustomTargetDir' to value ''
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'InstallAllUsersState' to value 'enabled'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'InstallLauncherAllUsersState' to value 'enabled'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'CustomInstallLauncherAllUsersState' to value '[InstallLauncherAllUsersState]'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'TargetDirState' to value 'enabled'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'CustomBrowseButtonState' to value 'enabled'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_core' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_exe' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_dev' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_lib' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_test' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_doc' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_tools' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_tcltk' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_pip' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_launcher' to value '1'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing string variable 
'Include_launcherState' to value 'enabled'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_symbols' to value '0'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'Include_debug' to value '0'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'LauncherOnly' to value '0'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'DetectedLauncher' to value '0'
[1D14:0FEC][2018-03-26T09:09:13]i000: Initializing numeric variable 
'DetectedOldLauncher' to 

[issue33153] interpreter crash when multiplying large tuples

2018-03-27 Thread Ivan Zakharyaschev

Ivan Zakharyaschev  added the comment:

It was run in i586 chroot on x86_64.

--

___
Python tracker 

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



[issue33153] interpreter crash when multiplying large tuples

2018-03-27 Thread Ivan Zakharyaschev

Ivan Zakharyaschev  added the comment:

The traceback:

[builder@localhost ~]$ python -c 'x = ("a", "b") * 2**20; x *= 2**20'
Segmentation fault (core dumped)
[builder@localhost ~]$ gdb python core.23284 
GNU gdb (GDB) 7.9-alt4 (ALT)
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i586-alt-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...Reading symbols from 
/usr/lib/debug/usr/bin/python2.7.debug...done.
done.

warning: core file may not match specified executable file.
[New LWP 23284]
Warning: couldn't activate thread debugging using libthread_db: Cannot find new 
threads: generic error
Warning: couldn't activate thread debugging using libthread_db: Cannot find new 
threads: generic error

warning: Unable to find libthread_db matching inferior's thread library, thread 
debugging will not be available.
Warning: couldn't activate thread debugging using libthread_db: Cannot find new 
threads: generic error
Warning: couldn't activate thread debugging using libthread_db: Cannot find new 
threads: generic error

warning: Unable to find libthread_db matching inferior's thread library, thread 
debugging will not be available.
Core was generated by `python -c x = ("a", "b") * 2**20; x *= 2**20'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  tuplerepeat (a=0xf694301c, n=1048576) at Objects/tupleobject.c:503
503 *p = items[j];
(gdb) bt
#0  tuplerepeat (a=0xf694301c, n=1048576) at Objects/tupleobject.c:503
#1  0xf7546d47 in sequence_repeat (n=0x80a83ac, seq=0xf694301c, 
repeatfunc=0xf75b24a0 ) at Objects/abstract.c:1210
#2  PyNumber_InPlaceMultiply (v=0xf694301c, w=0x80a83ac) at 
Objects/abstract.c:1374
#3  0xf7602ff8 in PyEval_EvalFrameEx (f=, throwflag=) at Python/ceval.c:1653
#4  0xf7608fee in PyEval_EvalCodeEx (co=0xf71a8ba8, globals=0xf7240714, 
locals=0xf7240714, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, 
defcount=0, closure=0x0) at Python/ceval.c:3589
#5  0xf760916e in PyEval_EvalCode (co=0xf71a8ba8, globals=0xf7240714, 
locals=0xf7240714) at Python/ceval.c:669
#6  0xf762c508 in run_mod (arena=0x8068320, flags=0xffa1a82c, 
locals=0xf7240714, globals=0xf7240714, filename=0xf765fec9 "", 
mod=) at Python/pythonrun.c:1376
#7  PyRun_StringFlags (str=0x804b160 "x = (\"a\", \"b\") * 2**20; x *= 
2**20\n", start=257, globals=0xf7240714, locals=0xf7240714, flags=0xffa1a82c) 
at Python/pythonrun.c:1339
#8  0xf762e160 in PyRun_SimpleStringFlags (command=0x804b160 "x = (\"a\", 
\"b\") * 2**20; x *= 2**20\n", flags=0xffa1a82c) at Python/pythonrun.c:974
#9  0xf764498e in Py_Main (argc=, argv=) at 
Modules/main.c:589
#10 0x080484f7 in main (argc=3, argv=0xffa1a974) at Modules/python.c:20
(gdb) quit
[builder@localhost ~]$ 

It was built like this -- 
http://git.altlinux.org/tasks/archive/done/_188/193020/build/100/i586/log :

i586-alt-linux-gcc -pthread -c -fno-strict-aliasing -pipe -Wall -g -O3 
-march=i586 -mtune=generic -DNDEBUG -pipe -Wall -g -O3 -march=i586 
-mtune=generic  -I. -IInclude -I./Include  -fPIC -DPy_BUILD_CORE -o 
Objects/tupleobject.o Objects/tupleobject.c

The same happens with gcc7-7.3.1-alt3 here -- 
http://git.altlinux.org/tasks/202598/build/100/i586/log .

--

___
Python tracker 

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



[issue33128] PathFinder is twice on sys.meta_path

2018-03-27 Thread Pablo Galindo Salgado

Change by Pablo Galindo Salgado :


--
keywords: +patch
pull_requests: +6001
stage: needs patch -> patch review

___
Python tracker 

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



[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

@Victor: So to make sure I understand, the point of the check is to complain 
about reference cycles involving thread objects, because when those happen in 
the stdlib you consider them bugs?

--

___
Python tracker 

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



[issue33128] PathFinder is twice on sys.meta_path

2018-03-27 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

The same problem happens in `new_interpreter` as far as I understand.

--

___
Python tracker 

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



Re: please test the new PyPI (now in beta)

2018-03-27 Thread Ian Kelly
On Mon, Mar 26, 2018 at 4:16 PM, Sumana Harihareswara  
wrote:
> The new Python Package Index at https://pypi.org is now in beta.
>
> This means the site is robust, but we anticipate needing more user
> testing and changes before it is "production-ready" and can fully
> replace https://pypi.python.org . We hope to complete the transition
> before the end of April 2018.
>
> We're still working to ensure the new codebase and infrastructure are
> reliable. So please don't rely on it (yet) unless you can handle the
> occasional minor outage.
>
> But we want you to try the new PyPI, test it, and tell us if you have
> any problems. During the beta, we'll have IRC and Twitter livechats to
> hear from you:

For me, the category filters alone are a killer feature over the old
PyPI. I think it's also a plus to the Python community overall that
PyPI not look to newcomers like something that was designed in the 90s
and then abandoned.

I agree with Steven about the unnecessary boxes around every single
package, though. The presentation of the list of packages could be
*much* denser while keeping the same readability, which would also
make the page more usable by reducing the amount of scrolling needed.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33128] PathFinder is twice on sys.meta_path

2018-03-27 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

It seems that the problem is that `_Py_InitializeEx_Private` calls  
`_Py_InitializeCore` and `_Py_InitializeMainInterpreter`. The first one calls 
at the end `initimport` that in turns calls 
`importlib._install_external_importers` that sets the PathFinder. Then, 
`_Py_InitializeMainInterpreter` calls  `initexternalimport` that in turns calls 
again `importlib._install_external_importers` and therefore we end with two 
PathFinders in sys.meta_path.

I think the solution is removing the call to initexternalimport in 
`_Py_InitializeMainInterpreter` as it has been alreade initialized by 
`_Py_InitializeCore`.

--
nosy: +pablogsal

___
Python tracker 

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



[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread Matthias Urlichs

Matthias Urlichs  added the comment:

> It's a deliberate choice. It helped me to find real bugs. For example, I 
> found a very old reference cycle in socket.create_connection().

Fair enough; I will change the patch to complain before gc'ing.

--

___
Python tracker 

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



Re: please test the new PyPI (now in beta)

2018-03-27 Thread Gregory Ewing

Paul Moore wrote:

maybe a less technical
term[1] like "filters" would help here?


Categories?

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread STINNER Victor

STINNER Victor  added the comment:

> This is not useful, esp. when the list of referrers to the "dangling" thread 
> looks like this: (...)

I wrote the test.bisect tool to help to debug dangling threads issues.

Sadly, sometimes the warning can occur randomly because of race conditions, and 
it can be painful to reproduce the bug, and to fix the root issues.

--

___
Python tracker 

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



[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread STINNER Victor

STINNER Victor  added the comment:

> Lib/test/support/__init__.py::threading_cleanup() complains about dangling 
> threads even if the reference in question would be cleaned up by the garbage 
> collector.

It's a deliberate choice. It helped me to find real bugs. For example, I found 
a very old reference cycle in socket.create_connection().

The error message ("dangling threads") doesn't help, but it means that 
"something is wrong" in your test.

Sadly, sometimes you have to explicitly do something like "self.thread = None" 
in your test.

I wrote an article to explain these things:
https://vstinner.github.io/contrib-cpython-2017q3-part2.html

Instead of calling support.gc_collect(), I suggest to write documentation, 
maybe as a comment in support.threading_cleanup()?, explaining the warning and 
how to fix it. Maybe with a link to this issue? :-)

--

___
Python tracker 

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



[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

Yes, a PR would be better... also, the two versions of the patch appear to be 
identical?

CC'ing Antoine and Victor b/c they seem to have written this dangling_threads 
checking stuff and I'm not sure I understand it :-).

As some extra background: this is in Python's internal testing code, but 
@smurfix is hitting it because he's working on a third-party asyncio event loop 
implementation, and re-using test.asyncio to test it. I'm not sure what 
specifically is causing this to happen, though I guess it has something to do 
with how trio / trio-asyncio are using threads.

[1] https://github.com/python-trio/trio-asyncio

--
nosy: +pitrou, vstinner

___
Python tracker 

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



Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Gregory Ewing

Rick Johnson wrote:

rb> Object.method("print_name").call("Meathead")


Yes, but the point is that you have to have to use a different
syntax to call it. This is like having to say

   f.__call__(arg)

in Python instead of just

   f(arg)

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Gregory Ewing

Chris Angelico wrote:

Ahh, that explains it. Great. So how do you build higher-order
functions? Or don't you?


You don't, exactly. You have to pass around objects
with a method to invoke when you want to "call" them.

Ruby has a code-block syntax that helps with this
somewhat, but I don't think you can invoke one with
the same syntax that you use for calling a method.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


[issue33160] Negative values in positional access inside formatting

2018-03-27 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Should str.format allow negative indexes when used for 
__getitem__ access?

___
Python tracker 

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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-27 Thread Ned Deily

Change by Ned Deily :


--
resolution:  -> fixed
stage: patch review -> 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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-27 Thread Ned Deily

Ned Deily  added the comment:


New changeset 6a2539c43412567a4c693da8e7fdf5e73191fd16 by Ned Deily in branch 
'3.7':
bpo-32517: re-enable test_read_pty_output on macOS (GH-6112)
https://github.com/python/cpython/commit/6a2539c43412567a4c693da8e7fdf5e73191fd16


--

___
Python tracker 

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



[issue32517] test_read_pty_output() of test_asyncio hangs on macOS 10.13.2 (darwin 17.3.0)

2018-03-27 Thread Ned Deily

Ned Deily  added the comment:


New changeset 8534d5e4e918be82b041754ecd89af519e5b by Ned Deily in branch 
'master':
bpo-32517: fix test_read_pty_output() hangs on macOS 10.13.2+ (GH-6037) 
(GH-6113)
https://github.com/python/cpython/commit/8534d5e4e918be82b041754ecd89af519e5b


--

___
Python tracker 

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



[issue33160] Negative values in positional access inside formatting

2018-03-27 Thread Ned Deily

Change by Ned Deily :


--
nosy: +eric.smith
type:  -> enhancement
versions: +Python 3.8 -Python 3.6

___
Python tracker 

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



[issue33160] Negative values in positional access inside formatting

2018-03-27 Thread Facundo Batista

New submission from Facundo Batista :

This works fine:

>>> "{[0]}".format([1, 2, 3])
'1'

This should work too:

>>> "{[-1]}".format([1, 2, 3])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: list indices must be integers or slices, not str

--
messages: 314549
nosy: facundobatista
priority: normal
severity: normal
status: open
title: Negative values in positional access inside formatting
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



Re: Pep8 for long pattern

2018-03-27 Thread Dan Stromberg
On Tue, Mar 27, 2018 at 8:18 AM, Michael Torrie  wrote:
> But when it's exactly what you need, why do
> you need to shoehorn the expression into 79 characters?  Seems pointless
> in a case like this. PEP8 is a guideline, not an absolute rule.  It's
> okay to bend it a bit in cases like this.

I think PEP8 specifying a max of 80 columns is very silly.

Even an old VT220 terminal could do 132 columns.

My understanding is that PEP8 requires 80 columns because a tiny,
tiny, tiny minority of Python developers wanted to be able to put 3
editors next to each other horizontally, without wrapping.

I like to check my code with pycodestyle, but I always override that
dang 80 column requirement.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread Christian Heimes

Christian Heimes  added the comment:

We generally prefer pull requests on github over patches on the bug tracker. 
Please follow the guidelines for contributing to CPython, 
https://devguide.python.org/pullrequest/

--
nosy: +christian.heimes

___
Python tracker 

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



[issue32850] Run gc_collect() before complaining about dangling threads

2018-03-27 Thread Matthias Urlichs

Matthias Urlichs  added the comment:

Apparently this patch has not been applied yet. Is there a reason for that, 
besides "it's obviously correct so there must be something wrong with it"? ;-)

--

___
Python tracker 

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



[issue33159] Implement PEP 473

2018-03-27 Thread Roundup Robot

Change by Roundup Robot :


--
keywords: +patch
pull_requests: +6000
stage:  -> patch review

___
Python tracker 

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



[issue33159] Implement PEP 473

2018-03-27 Thread skreft

New submission from skreft :

Implement PEP 473.

--
messages: 314546
nosy: skreft
priority: normal
severity: normal
status: open
title: Implement PEP 473
versions: Python 3.8

___
Python tracker 

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



[issue33155] Use super().method instead in Logging

2018-03-27 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
assignee:  -> vinay.sajip

___
Python tracker 

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



[issue25257] In subject line email library inserts unwanted space after a thousands comma in a number

2018-03-27 Thread Bob Hossley

Bob Hossley  added the comment:

Mike,

Thank you.

I moved to Python 3 some time ago.  I confirm that Python 3 does not
have the problem.  But I can't conveniently verify your workaround for
Python 2.

Regards,
Bob
bhoss...@ieee.org

On 2018-03-27 11:30 AM, Mike Edmunds wrote:
> 
> Mike Edmunds  added the comment:
> 
> Here's a workaround for Python 2.7:
> 
> ```
> class HeaderBugWorkaround(email.header.Header):
> def encode(self, splitchars=' ', **kwargs):  # only split on spaces, 
> rather than splitchars=';, '
> return email.header.Header.encode(self, splitchars, **kwargs)
> 
> # and then...
> 
> msg['Subject'] = HeaderBugWorkaround(subject, 'utf-8', header_name='Subject')
> 
> ```
> 
> (If you have the option, you're almost certainly better off moving to Python 
> 3 for anything email related. But if you're maintaining code that has to be 
> Python 2.7 compatible, this might help.)
> 
> --
> nosy: +medmunds
> 
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue25257] In subject line email library inserts unwanted space after a thousands comma in a number

2018-03-27 Thread Mike Edmunds

Mike Edmunds  added the comment:

Here's a workaround for Python 2.7:

```
class HeaderBugWorkaround(email.header.Header):
def encode(self, splitchars=' ', **kwargs):  # only split on spaces, rather 
than splitchars=';, '
return email.header.Header.encode(self, splitchars, **kwargs)

# and then...

msg['Subject'] = HeaderBugWorkaround(subject, 'utf-8', header_name='Subject')

```

(If you have the option, you're almost certainly better off moving to Python 3 
for anything email related. But if you're maintaining code that has to be 
Python 2.7 compatible, this might help.)

--
nosy: +medmunds

___
Python tracker 

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



[issue13829] exception error in _scproxy.so when called after fork

2018-03-27 Thread triccare triccare

triccare triccare  added the comment:

I have run into this bug which can be reliably reproduced by importing tkinter.

However, I have found another workaround if one does not want to deal with the 
environmental variable and may point to a possible bug fix. Before forking, any 
use of `urlopen` alleviates the bug. This is demonstrated in the attached 
example.

Example works under Python 3.6.4 and Mac OS 10.12.6

--
nosy: +triccare triccare
Added file: https://bugs.python.org/file47503/debug_urlopen.py

___
Python tracker 

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



testfixtures 6.0.0 released!

2018-03-27 Thread Chris Withers

Hi All,

I'm pleased to announce the release of testfixtures 6.0.0 featuring the 
following:


 * |compare()|
   
will
   now handle objects that do not natively support equality or
   inequality and will treat these objects as equal if they are of the
   same type and have the same attributes as found using|vars()|
   or|__slots__|.
   This is a change in behaviour which, while it could conceivably
   cause tests that are currently failing to pass, should not cause any
   currently passing tests to start failing.
 * Add support for writing to the|stdin|of|MockPopen|
   
instances.
 * The default behaviour of|MockPopen|
   
can
   now be controlled by providing a callable.
 * |LogCapture.actual()|
   
is
   now part of the documented public interface.
 * Add|LogCapture.check_present()|
   
to
   help with assertions about a sub-set of messages logged along with
   those that are logged in a non-deterministic order.
 * |Comparison|
   
now
   supports objects with|__slots__|.
 * Added|ShouldAssert|
   
as
   a simpler tool for testing test helpers.
 * Changed the internals of the various decorators testfixtures
   provides such that they can be used in conjunction
   with|unittest.mock.patch()|
   on
   the same test method or function.
 * Changed the internals of|ShouldRaise|
   
and|Comparison|
   
to
   make use of|compare()|
   
and
   so provide nested comparisons with better feedback. This finally
   allows|ShouldRaise|
   
to
   deal with Django’s|ValidationError|
   
.
 * Added handling of self-referential structures to|compare()|
   
by
   treating all but the first occurence as equal. Another change needed
   to support Django’s insane|ValidationError|
   
.

Thanks to Hamish Downer and Tim Davies for their work on|MockPopen| 
.


Thanks to Wim Glenn and Daniel Fortunov for their help reviewing some of 
the more major changes.


The package is on PyPI and a full list of all the links to docs, issue 
trackers and the like can be found here:


https://github.com/Simplistix/testfixtures

Any questions, please do ask on the Testing in Python list or on the 
Simplistix open source mailing list...


cheers,

Chris
--
https://mail.python.org/mailman/listinfo/python-list


[issue33151] importlib.resources breaks on subdirectories

2018-03-27 Thread Barry A. Warsaw

Change by Barry A. Warsaw :


--
resolution:  -> fixed
stage: patch review -> 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



[issue33151] importlib.resources breaks on subdirectories

2018-03-27 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:


New changeset fd1b8f87b3e63495cadd37c8f1b90191b46ee52a by Barry Warsaw (Miss 
Islington (bot)) in branch '3.7':
bpo-33151: Handle submodule resources (GH-6268) (GH-6270)
https://github.com/python/cpython/commit/fd1b8f87b3e63495cadd37c8f1b90191b46ee52a


--

___
Python tracker 

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



Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 11:35:31 AM UTC-5, Chris Angelico wrote:
> Why are you suggesting that this is magic?

_You_ are the one who leveled the accusation that Ruby's
methodology for fetching a function reference (a la):

Object.method(meth-name-here)

is "magic". I'm merely requesting that you defend _your_
accusation. That's all.

> Yep, one of the most misunderstood lines in the zen.
> "Explicit" means "stuff I like", and "implicit" means
> "stuff I don't like". Or at least, that's how I see this
> used.

Perhaps (and unfortunately) some folks in this community
interpret the zen as you claim, however, the words explicit
and implicit have clear definitions, and thus, to ascribe
them to personal "likes" is a miscarriage of both
comprehension and objectivity.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33158] Add fileobj property to csv reader and writer objects

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

> A fileobj property would be convenient, as you otherwise, for example, need 
> to pass an extra argument to routines that need both the csv object and the 
> underlying file object.

But you should already have this object for creating csv.reader() or 
csv.writer().

Even if keep the argument of the constructor as an instance attribute, there is 
a problem with naming this attribute. csv.reader works not only with files. It 
accepts arbitrary iterable.

>>> it = iter(['Spam, Spam, Spam, Spam, Spam, Baked Beans', 'Spam, Lovely Spam, 
>>> Wonderful Spam'])
>>> list(csv.reader(it))
[['Spam', ' Spam', ' Spam', ' Spam', ' Spam', ' Baked Beans'], ['Spam', ' 
Lovely Spam', ' Wonderful Spam']]

The dialect property is not a copy of the dialect constructer argument.

--
nosy: +serhiy.storchaka
versions:  -Python 2.7

___
Python tracker 

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



[issue33155] Use super().method instead in Logging

2018-03-27 Thread Mads Jensen

Change by Mads Jensen :


--
keywords: +patch
pull_requests: +5999
stage:  -> patch review

___
Python tracker 

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



[issue33151] importlib.resources breaks on subdirectories

2018-03-27 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5998

___
Python tracker 

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



[issue33151] importlib.resources breaks on subdirectories

2018-03-27 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:


New changeset 30e507dff465a31901d87df791a2bac40dc88530 by Barry Warsaw in 
branch 'master':
bpo-33151: Handle submodule resources (GH-6268)
https://github.com/python/cpython/commit/30e507dff465a31901d87df791a2bac40dc88530


--

___
Python tracker 

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



[issue32742] zipfile extractall needlessly re-wraps ZipInfo instances

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

There is an obscure behavior change introduced by this PR. Technically a ZIP 
file can contain several entries with the same name. Currently extractall() 
will extract the last of them multiple times.  The result doesn't differ from 
when extract it only once, there is just a waste of time. After merging this PR 
extractall() will extract different entries to the same location. If one of the 
is a directory, and other is a file, extractall() will fail.

I'm not sure it can be considered a valid ZIP file, but currently the zipfile 
module supports it.

On other hand, what is the benefit of using `self.infolist()` instead of 
`self.namelist()`?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Chris Angelico
On Wed, Mar 28, 2018 at 3:28 AM, Rick Johnson
 wrote:
> On Tuesday, March 27, 2018 at 8:46:54 AM UTC-5, Chris Angelico wrote:
> [...]
>> Cool, so Greg was right: you can't get a reference to a
>> method or function. You need magic to simulate it.
>
> Since when did utilizing a method to request a specific
> value become some sort of magic?
>
> Do you consider this to be magic?
>
> os.lstdir('C:\\')

That requests the "lstdir" method of the "os" object, most likely a
module. And then it calls that. Nope, not magic. When you use the name
"os", you get the object referenced by that name. When you put a dot
after an object, you get an attribute of that object. When you put
parentheses after an object, you call it. Why would it be magic?

> What about this?
>
> ''.join(map(chr, [109, 101, 97, 116, 32, 104, 101, 97, 100]))
>

You have a string literal, and you get a method off that object.
Etcetera. Why are you suggesting that this is magic?

> Even though i prefer Python's way better, the implicit
> return of Python function references is far more "magical"
> than making an explicit call to a method will ever be.
>
> Python Zen Says: "Explicit is better than implicit"

Yep, one of the most misunderstood lines in the zen. "Explicit" means
"stuff I like", and "implicit" means "stuff I don't like". Or at
least, that's how I see this used.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 8:46:54 AM UTC-5, Chris Angelico wrote:
[...]
> Cool, so Greg was right: you can't get a reference to a
> method or function. You need magic to simulate it.

Since when did utilizing a method to request a specific
value become some sort of magic?

Do you consider this to be magic?

os.lstdir('C:\\')

What about this?

''.join(map(chr, [109, 101, 97, 116, 32, 104, 101, 97, 100]))

Even though i prefer Python's way better, the implicit
return of Python function references is far more "magical"
than making an explicit call to a method will ever be.

Python Zen Says: "Explicit is better than implicit"

Hmm, i suppose Python's constancy is overrated[1]. 

[1] Which is merely a nice way of saying: "It's a lie!".
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33158] Add fileobj property to csv reader and writer objects

2018-03-27 Thread Samwyse

New submission from Samwyse :

Many objects have properties that allow access to the arguments used to create 
them.  In particular, file objects have a name property that returns the name 
used when opening a file.  A fileobj property would be convenient, as you 
otherwise, for example, need to pass an extra argument to routines that need 
both the csv object and the underlying file object.  Adopting this enhancement 
would also provide consistency with the dialect constructer argument, which is 
available as an object property.

Changing the fileobj while the csv object is in use would open a can of worms, 
so this should be a read-only property.

Optionally, the fileobj property could be reflected in the DictReader and 
DictWriter classes, but the value would be accessible via the .reader and 
.writer properties of those classes.

--
components: Library (Lib)
messages: 314538
nosy: samwyse
priority: normal
severity: normal
status: open
title: Add fileobj property to csv reader and writer objects
type: enhancement
versions: Python 2.7, Python 3.8

___
Python tracker 

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



Re:

2018-03-27 Thread Dan Stromberg
Please at least skim http://www.catb.org/esr/faqs/smart-questions.html

On Tue, Mar 27, 2018 at 12:27 AM, kevon harris  wrote:
> Unable to pull up IDLE after downloading Python 3.6.4
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33144] random._randbelow optimization

2018-03-27 Thread Wolfgang Maier

Wolfgang Maier  added the comment:

Thanks, Raymond. I'll do that once I've addressed Serhiy's points.

--

___
Python tracker 

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



[issue33144] random._randbelow optimization

2018-03-27 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Wolfgang, can you submit this as a PR.

--

___
Python tracker 

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



[issue31550] Inconsistent error message for TypeError with subscripting

2018-03-27 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Marked as closed for the reasons listed.

Thank you for the suggestion, but we're going to decline.

--
resolution:  -> rejected
stage: patch review -> 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



[issue33144] random._randbelow optimization

2018-03-27 Thread Wolfgang Maier

Wolfgang Maier  added the comment:

Serhiy:

> I like the idea in general, but have comments about the implementation.
> 
> __init_subclass__ should take **kwargs and pass it to 
> super().__init_subclass__(). type(cls.random) is not the same as 
> type(self.random). I would use the condition `cls.random is 
> _random.Random.random` instead, or check if the method is in cls.__dict__.
> 
> This will break the case when random or getrandbits methods are patched after 
> class creation or per instance, but I think we have no need to support this.
> 

My bad, sorry, and thanks for catching all these issues!

You're absolutely right about the class type checks not being equivalent 
to the original ones at the instance level.
Actually, this is due to the fact that I first moved the checks out of 
_randbelow and into __init__ just as Raymond would have done and tested 
this, but then I realized that __init_subclass__ looked just like the 
right place and moved them again - this time without testing on derived 
classes again.
 From a quick experiment it looks like types.MethodDescriptorType would 
be the correct type to check cls.random against and types.FunctionType 
would need to be checked against cls.getrandbits, but that starts to 
look rather esoteric to me - so you are probably right that something 
with a cls.__dict__ check or the alternative suggestion of `cls.random 
is _random.Random.random` are better solutions, indeed.

> We could support also the following cases:
> 
> 1.
>  class Rand1(Random):
>  def random(self): ...
>  # _randbelow should use random()
> 
>  class Rand2(Rand1):
>  def getrandbits(self): ...
>  # _randbelow should use getrandbits()
>  # this is broken in the current patch
> 

Right, hadn't thought of this situation.

> 2.
>  class Rand1(Random):
>  def getrandbits(self): ...
>  # _randbelow should use getrandbits()
> 
>  class Rand2(Rand1):
>  def random(self): ...
>  # _randbelow should use random()
>  # this is broken in the current code
> 

May be worth fixing, too.

--

___
Python tracker 

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



[issue33157] Strings beginning with underscore not removed from lists - feature or bug?

2018-03-27 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

In addition to Xiang Zhang's comments, this is neither a feature nor a bug, but 
a misunderstanding. This has nothing to do with strings or underscores:

py> L = [1, 2, 3, 4, 5]
py> for item in L:
... L.remove(item)
...
py> L
[2, 4]


When you modify a list as you iterate over it, the results can be unexpected. 
Don't do it.

If you *must* modify a list that you are iterating over, you must do so 
backwards, so that you are only removing items from the end, not the beginning 
of the list:

py> L = [1, 2, 3, 4, 5]
py> for i in range(len(L)-1, -1, -1):
... L.remove(L[i])
...
py> L
[]


But don't do that: it is nearly always must faster to make a copy of the list 
containing only the items you wish to keep, then assign back to the list using 
slicing. A list comprehension makes this an easy one-liner:

py> L = [1, 2, 3, 4, 5]
py> L[:] = [x for x in L if x > 4]
py> L
[5]

--
nosy: +steven.daprano

___
Python tracker 

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



[issue33157] Strings beginning with underscore not removed from lists - feature or bug?

2018-03-27 Thread Xiang Zhang

Xiang Zhang  added the comment:

You may refer to stackoverflow for an explanation, for example, 
https://stackoverflow.com/questions/6260089/strange-result-when-removing-item-from-a-list

--

___
Python tracker 

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



Re: String Formatting with new .format()

2018-03-27 Thread Michael Torrie
On 03/26/2018 09:37 AM, Ganesh Pal wrote:
> Hi Team,
> 
> Just a quick suggestion, on string formatting with .format() which of the
> below is better , given both give the same result .

No they don't. Look more closely at the output.

 attempts = 1
 msg2 = "Hello"
 print "Retry attempt:{0} for error:{1}".format(attempts,msg2)
> Retry attempt:1 for error:Hello
^
> 
> OR
> 
 attempts = 1
 msg2 = "Hello"
 print "Retry attempt:{0} for error:{0}".format(attempts,msg2)
> Retry attempt:1 for error:1
^^
The second example places the same argument 0 in two places in your
string.  This is not what you want, I don't think.

> PS : This is the silly question but I wanted to know if it really makes any
> difference

What makes any difference?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33157] Strings beginning with underscore not removed from lists - feature or bug?

2018-03-27 Thread Xiang Zhang

Xiang Zhang  added the comment:

It's just the right behavior. You are modifying the list while iterating over 
it. It has no business of underscore.

>>> test = ['_a', 'a', '_b', 'b']
>>> for i in test: test.remove(i)
>>> test
['a', 'b']

--
nosy: +xiang.zhang
resolution:  -> not a bug
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



Re: Pep8 for long pattern

2018-03-27 Thread Michael Torrie
On 03/27/2018 08:17 AM, Ganesh Pal wrote:
> Hello Python friends,
> 
> How do I split the below regex , so that it fits within the  character
> limit of 79 words
> 
> 
> pattern =  [
> r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
> 
> r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
> '.']
> 
> I am using Python 2.7 + Linux

I like Serhiy's idea of using fixed number repetition to shorten the
expressions and make them more readable.  Now it could be that in
general a long regular expression is a bad idea (maybe a simple split()
is the way to go instead).  But when it's exactly what you need, why do
you need to shoehorn the expression into 79 characters?  Seems pointless
in a case like this. PEP8 is a guideline, not an absolute rule.  It's
okay to bend it a bit in cases like this.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33157] Strings beginning with underscore not removed from lists - feature or bug?

2018-03-27 Thread yemiteliyadu

New submission from yemiteliyadu :

Strings beginning with underscore not removed from lists
Reproducible as shown below:

Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> test = ["a","_a","b","_b"]
>>> for i in test: print(i)
... 
a
_a
b
_b
>>> for i in test: test.remove(i)
... 
>>> test
['_a', '_b']
>>> 

Is this a feature or a bug?
A search through the docs did not show any mention of this.

--
messages: 314530
nosy: yemiteliyadu
priority: normal
severity: normal
status: open
title: Strings beginning with underscore not removed from lists - feature or 
bug?
type: behavior
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



[issue33152] Use list comprehension in timeit module instead of loop with append

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

We usually do not do such kind of changes due to the risk of introducing new 
bugs (as your PR demonstrated). Only when other changes are applied to the 
module, the surrounded code can be cleaned up. Or the maintainer of the module 
can do this if he decided that it is a time for modernization.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue33152] Use list comprehension in timeit module instead of loop with append

2018-03-27 Thread Pablo Galindo Salgado

Change by Pablo Galindo Salgado :


--
title: clean code -> Use list comprehension in timeit module instead of loop 
with append

___
Python tracker 

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



Re: To super or not to super (Re: Accessing parent objects)

2018-03-27 Thread Steven D'Aprano
On Tue, 27 Mar 2018 19:21:38 +1300, Gregory Ewing wrote:

> The idea that super() is *always* the right way to call inherited
> methods in a multiple inheritance environment seems to have been raised
> by some people to the level of religous dogma.

"Always"?

Well, you could always avoid super() by reinventing the wheel and 
creating your own (slow, buggy) method of dealing with inheritance in a 
MI environment.

*wink*

Since I've been the one hammering the idea that super is necessary to do 
MI correctly in Python, you're probably referring to me in your "dogma" 
comment.

I should say that in my defence I'm not talking about the case where you 
are expert enough to know when and how to break the rules, and have 
absolute and total control of what classes subclass yours.

Please forgive: I naturally always think of writing classes for public 
consumption, and tend to forget that sometimes people write classes for 
themselves or a small team ruled by a leader with an iron fist :-)

So I guess that if you are in a position to control who and what 
subclasses your class, and are prepared to blame the subclass for any 
inheritance bugs ("we didn't say doing that was supported"), then you can 
do whatever you like and super is not necessary.

Comments on your additional points below:


> I don't buy it. In order for it to work, the following two conditions
> must hold:
> 
> 1) All the methods involved have "additive" behaviour, i.e. the correct
> thing to do is always to call *all* versions of the method with the same
> arguments.
> 
> 2) It doesn't matter what order they're called in.

I think that the first condition may be a requirement of all cooperative 
MI, and I think the second one is wrong.

In the most general case, of course order matters: if class A reads to a 
file, and class B deletes it, then you can't call B first then A. That's 
the nature of inheritance, whether multiple or single. There may be 
*some* tasks that can be performed in whatever arbitrary method you think 
of, but they're surely a small minority.


> The trouble is, those conditions don't always hold. Often when
> overriding a method, you want to do something *instead* of what the base
> method does. 

That is the definition of "overriding": when you don't call the 
superclass at all, but entirely override its behaviour.


> Or you want to do something additional, but the base method
> must be called *first*.

That's not a problem. There's no restriction on when you call super:

def method(self, arg):
super().method(arg)
# do my stuff second


def method(self, arg):
# do my stuff first
super().method(arg)


are both perfectly legitimate.


But suppose I subclass two classes, Spam and Eggs. Why would I subclass 
both of them if I didn't want to inherit *both* their behaviour?

I can certainly envisage situations where I want to override both 
classes, e.g the __repr__ of the subclass probably doesn't want to call 
either Spam.__repr__ or Eggs.__repr__. But of course that's easy: just 
don't call super in the subclass' __repr__.

I don't think it is very controversial that there are methods which we 
don't want to inherit from the superclasses, such as __repr__, so I shall 
ignore them. They're not the "interesting" methods that include the 
"business logic" of your class.

So let's just ignore anything that you want to *override* (i.e. don't 
call the superclass methods at all) and only consider those you want to 
*overload*.

If you push me into a corner, I suppose I will have to say that in 
principle, I might want to inherit Spam.foo but not Eggs.foo. But 
honestly, that feels dirty: it breaks the Liskov Substitution principle.

https://en.wikipedia.org/wiki/Liskov_substitution_principle


So given three classes and an instance:

class Spam: ...
class Eggs: ...
class Breakfast(Spam, Eggs): ...

obj = Breakfast()

anyone using obj should be entitled to expect that obj.foo meets the 
contracts provided by *both* Spam and Eggs. After all, obj is an Eggs 
instance: if obj.foo doesn't call Eggs.foo, that's going to break 
anything that expects that isinstance(obj, Eggs) implies that obj obeys 
Eggs' contracts.

So you better have a damn good reason for inconsistently overloading 
methods in this way, and your callers better understand exactly why 
you're threatening to break their code if they rely on Eggs contracts.

(I'm not talking about Eiffel-style Design-By-Contract contracts here, 
but the more informal contracts offered by class interfaces.)


So I think that the moment you start talking about picking and choosing 
which superclass methods you inherit from, you're in "Hey hold my beer 
while I try something, I saw it in a cartoon but I'm pretty sure it will 
work" territory.

Or possibly even in the "tequila plus handguns" zone.

But hey, consenting adults and all that, so if you really know what 
you're doing, go for it. Who needs all ten toes?

*wink*


[...]
> In those 

Re: (unknown)

2018-03-27 Thread Grant Edwards
On 2018-03-27, kevon harris  wrote:

> Unable to pull up IDLE after downloading Python 3.6.4

Ah.  What happens when you push down instead of pull up?

> Sent from Mail for Windows 10

Sent from mutt for Gentoo Linux 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To super or not to super (Re: Accessing parent objects)

2018-03-27 Thread Ian Kelly
On Tue, Mar 27, 2018 at 8:47 AM, Ian Kelly  wrote:
> On Tue, Mar 27, 2018 at 12:21 AM, Gregory Ewing
>  wrote:
>> The trouble is, those conditions don't always hold.
>> Often when overriding a method, you want to do something
>> *instead* of what the base method does.
>
> As noted above, unless the method or class is abstract then this
> violates LSP. If the method is abstract and does nothing, then just
> call it. If the method is abstract and raises an exception, then
> that's a little more tricky. Ideally, don't write abstract methods
> that raise NotImplementedError unless they're not intended to be used
> with multiple inheritance.
>
> If you really need to though, you can solve this by creating a guard
> class that implements the method and does nothing, ending the super
> call chain. Then just make sure that at least one subclass in the
> multiple inheritance diagram inherits from the guard class rather than
> the original class.

Er, this should say "make sure that every subclass ... inherits from
the guard class ..." since we want to make sure that nothing else ends
up between the guard class and the original class.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33111] Merely importing tkinter breaks parallel code (multiprocessing, sharedmem)

2018-03-27 Thread Ethan Welty

Ethan Welty  added the comment:

@ronaldoussoren: The order of the imports made no difference. Even with the 
call at the top, I got endless errors with both 'spawn' and 'forkserver', with 
or without importing a graphics backend. Only 'fork' works, and only if a 
graphics package is not imported.

** HOWEVER **

Setting method='spawn' or 'forkserver' and force=True at top, or calling 
multiprocessing.set_start_method in __main__ does work (when run as scripts 
from command line). It's a shame to have to give up the convenience of 'fork', 
but this is a start.

```
import multiprocessing
multiprocessing.set_start_method("spawn", force=True)
import numpy as np
# import _tkinter

def parallel_matmul(x):
R = np.random.randn(3, 3)
return np.matmul(R, x)

if __name__ == '__main__':
# multiprocessing.set_start_method("spawn", force=False)
pool = multiprocessing.Pool(4)
results = pool.map(parallel_matmul, [np.random.randn(3, 5000) for i in 
range(2)])
```

--

___
Python tracker 

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



Re: To super or not to super (Re: Accessing parent objects)

2018-03-27 Thread Ian Kelly
On Tue, Mar 27, 2018 at 12:21 AM, Gregory Ewing
 wrote:
> The idea that super() is *always* the right way to call
> inherited methods in a multiple inheritance environment
> seems to have been raised by some people to the level
> of religous dogma.
>
> I don't buy it. In order for it to work, the following
> two conditions must hold:
>
> 1) All the methods involved have "additive" behaviour,
> i.e. the correct thing to do is always to call *all*
> versions of the method with the same arguments.

I would argue that this is just good OO design. Inheritance with
subtractive behavior violates the Liskov substitution principle.

> 2) It doesn't matter what order they're called in.

This is simply not true. The Python MRO is very specific about the
order they will be called in, and it obeys some important rules:

1) Monotonicity - If the MRO of class C has class B1 before B2, then
the MRO of any subclass of C must also have B1 before B2.

2) Local precedence ordering - If C inherits directly from B1 and B2
in that order, then its MRO must have B1 before B2.

The algorithm used is also precisely specified, so in cases where
these rules would permit more than one possible ordering, the actual
MRO can be determined by running the algorithm.

> The trouble is, those conditions don't always hold.
> Often when overriding a method, you want to do something
> *instead* of what the base method does.

As noted above, unless the method or class is abstract then this
violates LSP. If the method is abstract and does nothing, then just
call it. If the method is abstract and raises an exception, then
that's a little more tricky. Ideally, don't write abstract methods
that raise NotImplementedError unless they're not intended to be used
with multiple inheritance.

If you really need to though, you can solve this by creating a guard
class that implements the method and does nothing, ending the super
call chain. Then just make sure that at least one subclass in the
multiple inheritance diagram inherits from the guard class rather than
the original class.

> Or you want to
> do something additional, but the base method must be
> called *first*.

I don't see why this is a problem; you can easily do other things
before calling super().

> On the other hand, explicit inherited method calls give
> you precise control over what happens and what order it
> happens in, with no chance of it being messed up by
> someone ineriting from you.

Unless they create a diamond in the process. Also, note even without
using super, the MRO is still used when deciding which version of an
inherited method to call if the subclass does not directly define it.
So you may end up accidentally creating a class structure that uses
one order for some methods and a different order for others. Using
super ensures that your calls follow the MRO.

> Yes, diamonds can be a problem. You can mitigate that
> by (1) avoiding diamonds;

Which can only be accomplished by not using multiple inheritance at all.

> (2) if you can't avoid
> diamonds, avoid putting methods in the apex class that
> get called as inherited methods;

Then what purpose does the apex class serve?

> (3) if you can't avoid
> either of those, as far as I can tell the situation is
> intractable and you need to rethink your design.

Or you can use super.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33149] Parser stack overflows

2018-03-27 Thread Ned Deily

Change by Ned Deily :


--
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



Re: Pep8 for long pattern

2018-03-27 Thread Serhiy Storchaka

27.03.18 17:17, Ganesh Pal пише:

How do I split the below regex , so that it fits within the  character
limit of 79 words


pattern =  [
r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',

r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
 '.']


For example:

pattern =  [
r'(?P('
r'[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:'
r':HEAD))',
r'(?P(owner:\s+'
r'[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:'
r':HEAD))',
'.']

Or just use fixed number repetition:

pattern =  [
r'(?P((?:[0-9a-fA-F]+:){5}:HEAD))',
r'(?P(owner:\s+(?:[0-9a-fA-F]+:){5}:HEAD))',
'.']

--
https://mail.python.org/mailman/listinfo/python-list


Re: Pep8 for long pattern

2018-03-27 Thread Paul Moore
Use re.X - see https://docs.python.org/3.6/library/re.html#re.X for details.

On 27 March 2018 at 15:17, Ganesh Pal  wrote:
> Hello Python friends,
>
> How do I split the below regex , so that it fits within the  character
> limit of 79 words
>
>
> pattern =  [
> r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
>
> r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
> '.']
>
> I am using Python 2.7 + Linux
>
> Regards,
> Ganesh
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Pep8 for long pattern

2018-03-27 Thread Ganesh Pal
Hello Python friends,

How do I split the below regex , so that it fits within the  character
limit of 79 words


pattern =  [
r'(?P([0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',

r'(?P(owner:\s+[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+:[0-9a-fA-F]+::HEAD))',
'.']

I am using Python 2.7 + Linux

Regards,
Ganesh
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32861] urllib.robotparser: incomplete __str__ methods

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

The default entry was moved out of entries added in issue523041, but 
RobotFileParser.__str__ was not updated. Support for "Crawl-delay" and 
"Request-Rate" was added in issue16099, but Entry.__str__ was not updated. This 
looks like bugs to me, and I think the fix should be backported.

But two unnecessary trailing newlines should be kept for compatibility in 
maintained versions. I think we can get rid of them in 3.8 (unless Senthil has 
other opinion).

--
nosy: +serhiy.storchaka
versions: +Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

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



Re: please test the new PyPI (now in beta)

2018-03-27 Thread Bill Deegan
The back ground blue on the pypi page is the highlight blue on the
python.org page, they should change the color to match to background
python.org color.

-Bill




On Tue, Mar 27, 2018 at 7:50 AM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Tue, 27 Mar 2018 22:25:44 +1100, Chris Angelico wrote:
>
> > On Tue, Mar 27, 2018 at 9:49 PM, Steven D'Aprano
> >  wrote:
> >> As an extra bonus, even when searching is not reliant on Javascript,
> >> mangling the text in the search box often is, so unless I'm extra
> >> careful, whenever I want to search for (say) "aardvarks", I invariably
> >> end up searching for "searaardvarksch".
> >>
> >> At least the new PyPI search box is better than that. They get a point.
> >>
> >>
> > "Mangling the text" should never be necessary. The HTML5  tag has
> > a 'placeholder' attribute for a reason.
>
>
> You're assuming the page is using HTML5. I've used a lot of these that
> did it in Javascript, and didn't degrade gracefully if Javascript was
> disabled.
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: please test the new PyPI (now in beta)

2018-03-27 Thread Chris Angelico
On Tue, Mar 27, 2018 at 10:50 PM, Steven D'Aprano
 wrote:
> On Tue, 27 Mar 2018 22:25:44 +1100, Chris Angelico wrote:
>
>> On Tue, Mar 27, 2018 at 9:49 PM, Steven D'Aprano
>>  wrote:
>>> As an extra bonus, even when searching is not reliant on Javascript,
>>> mangling the text in the search box often is, so unless I'm extra
>>> careful, whenever I want to search for (say) "aardvarks", I invariably
>>> end up searching for "searaardvarksch".
>>>
>>> At least the new PyPI search box is better than that. They get a point.
>>>
>>>
>> "Mangling the text" should never be necessary. The HTML5  tag has
>> a 'placeholder' attribute for a reason.
>
>
> You're assuming the page is using HTML5. I've used a lot of these that
> did it in Javascript, and didn't degrade gracefully if Javascript was
> disabled.
>

Any time you see something that requires JavaScript for this, you know
you've found a web site that dates back to... uhh, actually I don't
know. I only have versioning info on MDN back as far as HTML 4.01 ergo
1999, and the placeholder attribute is there. Of course, that doesn't
mean everyone *used* it, but it was certainly available.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (unknown)

2018-03-27 Thread Terry Reedy

On 3/27/2018 3:27 AM, kevon harris wrote:

Unable to pull up IDLE after downloading Python 3.6.4


What did you download?
How did you install after downloading?
Can you run 3.6 after installing?
How did you try to run IDLE?
Can you use Command Prompt?

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Chris Angelico
On Tue, Mar 27, 2018 at 11:00 PM, Rick Johnson
 wrote:
> On Tuesday, March 27, 2018 at 1:55:01 AM UTC-5, Gregory Ewing wrote:
>> Chris Angelico wrote:
>> > Question: How do you get a reference to a Ruby function? Or are they
>> > not first-class objects?
>>
>> They're not first-class. So, you can't.
>
> If Chris means: "how do you get a reference to a Ruby
> function object", then yes, it _is_ possible! Consider the
> following:
>
> ## Ruby 1.9 ##
> rb> def print_name(name); puts "Your name is #{name.inspect}"; end
> rb> print_name("Chris")
> "Chris"
>
> In this case, since the function `print-name` was defined
> outside of an class definition, Ruby will add the function
> as a method of `Object` (Ruby is more purist about OOP than
> Python). So, to get a reference to the function object
> (which is now a method of `Object`!), all we need to do is
> call a method named "method" ("gigity") and pass it the name
> of the method as a string:
>
> rb> Object.method("print_name")
> #
> rb> Object.method("print_name").call("Meathead")
> Your name is "Meathead"
>
> PS: Greg, please inform Chris that Google is his friend. ;-)

Cool, so Greg was right: you can't get a reference to a method or
function. You need magic to simulate it.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33156] Use super().method instead in email classes.

2018-03-27 Thread R. David Murray

R. David Murray  added the comment:

Thank you for wanting to improve Python, but unless this is actually causing a 
problem for someone, there is a greater chance of introducing a bug by making 
such changes than the benefit of the "cleanup".  So we generally don't accept 
such patches.  If we modify the code for other reasons (ie: we might already be 
introducing new bugs), then we make such changes.

--
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



[issue33014] Clarify str.isidentifier docstring; fix keyword.iskeyword docstring

2018-03-27 Thread R. David Murray

R. David Murray  added the comment:

I think my wording would be an improvement to the docs as well.  You could link 
just the keyword function if you are worried about too many links, since that 
would keep the link count the same.

--

___
Python tracker 

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



[issue33146] contextlib.suppress should capture exception for inspection and filter on substrings

2018-03-27 Thread Nick Coghlan

Nick Coghlan  added the comment:

I wouldn't expand the scope of contextlib.suppress, since it has a pretty clear 
purpose: pretend the exception never happened. (This was even clearer with the 
original "ignored" name, before I was talked into changing it to use the 
current more technically correct, but far less intuitive, name - a decision I 
still regret).

However, when writing tests, or otherwise introspecting thrown exceptions (i.e. 
in programs about programs), it's not uncommon for me to want a construct like:

with catch(FileNotFoundError) as err:
os.remove(somefile)

if err.caught is not None:
...

The benefit over the try/catch form is similar to the benefits of suppress:

1. Up front declaration that that kind of exception isn't going to escape and 
execution will continue after the suite
2. More efficient use of vertical whitespace (one extra line instead of three)

In this case, we could also end up expanding the API to provide a better 
building block for testing tools like "assertRaises" and "assertRaisesRegex" by 
accepting a "filter" callback argument that receives the caught exception, and 
can either return False to suppress it, True to reraise it, or explicitly raise 
a different exception to replace it. (That suggested callback API is 
deliberately similar to an __exit__ implementation that only accepts the 
exception value, rather than the full type/value/traceback triple).

(The simpler name may mean that folks end up preferring catch() to suppress() 
even when they don't need the result of __enter__. I'd be OK with that outcome).

--

___
Python tracker 

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



Re: String Formatting with new .format()

2018-03-27 Thread Ganesh Pal
>
>
> Or maybe they're not giving the same result. I'm a little confused here.
>
>
 Thanks  Chris, for the reply they appear to give the same result .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 7:19:53 AM UTC-5, kevon harris wrote:
> Unable to pull up IDLE after downloading Python 3.6.4
> 
> Sent from Mail for Windows 10

What OS?

On Windows running Python2.X, IDLE is located @ '/Python2X/Lib/idlelib/idle.pyw'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 3:24:48 AM UTC-5, Steven D'Aprano wrote:
> On Mon, 26 Mar 2018 11:37:35 -0700, Rick Johnson wrote:

> Printing a string and calling a function is obfuscated code? Deary me.

When the programmer can't be bothered to invent names more
descriptive than `a` and `b`, why yes, yes it is.

> And besides, while I'm more than happy to take (undeserved)
> credit for all the things Ruby gets right, I draw the line
> at being blamed for Ruby misfeatures like parens-less
> function calls, and the inconsistent behaviour they lead
> to.

What version are you testing this "misfeature" on?
Personally, I'm using 1.9, so i have no idea if the
"misfeature" has been repaired or not. The latest stab;e
release is 2.5.0. There have been a ton of changes since
1.9!

> > > Because of this "fix", the printed strings no longer
> > > match the code being executed, but the strange,
> > > inconsistent behaviour still occurs.
> > 
> > The supposed "inconsistent behavior" here has absolutely
> > nothing to do with Ruby, no, it's all on _you_. _YOU_ are
> > the one who created a non-sensical function
> 
> I love watching you trying to squirm your way out of
> admitting that you screwed up. Returning the input plus two
> is nonsensical is it?

When the function is named `a`, why yes, yes it is!

> As I said, don't blame me for Ruby's poor design.  By the
> way, there are precisely the same number of clues that:  a
> is a function as there are for:  super  in Ruby. But you
> know that, because you were vehemently defending the use of
> super with no parens and why it isn't inconsistent for it
> to do something completely different from super() with
> parens.

Okay, Mr. "Language Designer"... how do _you_ propose to
implement Ruby's super in a way that provides these same
three distinct forms:

(1) implicit passing of args: `super`
(2) explicit passing if args: `super(arg1, arg2, ..., argN)`
(3) no arg passing: `super()`

Let's hear it! And don't forget to make your design
consistent with func/meth calls, even though super is not a
func at all -- but i digress!

> So now you're claiming I hacked the Ruby interpreter to
> support non- standard code? I can smell the desperation in
> you from the other side of the planet.  Rick, nothing I did
> was illegal Ruby code. Everything I did was 100% following
> the rules of the Ruby language.

The rules you violated were _style_ and _sanity_ rules.
Every wise programmer knows that readability dictates one
space on each side of an operator:

YES: a + b
NO: a+b
NO: a+ b
NO: a +b
HELL NO: a+   b

Ruby is punishing you for your petulant behavior. And if i
were you, i'd be kissing Matz's backside for only giving you
a "surprising result". Because if *I* were the creator of
Ruby, i'd have Ruby format your hard-drive for doing _less_.

But i look forward to your proposed solutions to Ruby's so-
called "broken expressions and inconsistent super". Oh guru,
please enlighten us with your language design wisdom.
-- 
https://mail.python.org/mailman/listinfo/python-list


condition.acquire vs lock.acquire

2018-03-27 Thread jayshankar nair via Python-list
Hi,
Is condition.acquire(threading.Condition()) similar to 
lock.acquire(threading.Lock). Does both of get access to the lock. Can i use 
condition.wait,notify with lock.acquire or i have to use condition.wait, notify 
with condition.acquire.
cond.acquire()  // can i replace with lock.acquire

   while count[ipID]> 1:
  cond.wait()
   if ipID == 0:
  time.sleep(10)


   count[ipID] = count[ipID] + 1


   cond.release() // can i replace with lock.release

Thanks,Jayshankar
-- 
https://mail.python.org/mailman/listinfo/python-list


[no subject]

2018-03-27 Thread kevon harris
Unable to pull up IDLE after downloading Python 3.6.4

Sent from Mail for Windows 10

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ruby parens-free function calls [was Re: Accessing parent objects]

2018-03-27 Thread Rick Johnson
On Tuesday, March 27, 2018 at 1:55:01 AM UTC-5, Gregory Ewing wrote:
> Chris Angelico wrote:
> > Question: How do you get a reference to a Ruby function? Or are they
> > not first-class objects?
>
> They're not first-class. So, you can't.

If Chris means: "how do you get a reference to a Ruby
function object", then yes, it _is_ possible! Consider the
following:

## Ruby 1.9 ##
rb> def print_name(name); puts "Your name is #{name.inspect}"; end
rb> print_name("Chris")
"Chris"

In this case, since the function `print-name` was defined
outside of an class definition, Ruby will add the function
as a method of `Object` (Ruby is more purist about OOP than
Python). So, to get a reference to the function object
(which is now a method of `Object`!), all we need to do is
call a method named "method" ("gigity") and pass it the name
of the method as a string:

rb> Object.method("print_name")
#
rb> Object.method("print_name").call("Meathead")
Your name is "Meathead"

PS: Greg, please inform Chris that Google is his friend. ;-)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32569] Blake2 module, memory clearance update

2018-03-27 Thread David CARLIER

David CARLIER  added the comment:

Little update it has been accepted and merged today :

https://github.com/BLAKE2/libb2/commit/620681a3b15c4d7239b9323b9da5ea208a959d3d

--
nosy: +David CARLIER2

___
Python tracker 

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



Re: please test the new PyPI (now in beta)

2018-03-27 Thread Steven D'Aprano
On Tue, 27 Mar 2018 22:25:44 +1100, Chris Angelico wrote:

> On Tue, Mar 27, 2018 at 9:49 PM, Steven D'Aprano
>  wrote:
>> As an extra bonus, even when searching is not reliant on Javascript,
>> mangling the text in the search box often is, so unless I'm extra
>> careful, whenever I want to search for (say) "aardvarks", I invariably
>> end up searching for "searaardvarksch".
>>
>> At least the new PyPI search box is better than that. They get a point.
>>
>>
> "Mangling the text" should never be necessary. The HTML5  tag has
> a 'placeholder' attribute for a reason.


You're assuming the page is using HTML5. I've used a lot of these that 
did it in Javascript, and didn't degrade gracefully if Javascript was 
disabled.



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33153] interpreter crash when multiplying large tuples

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

tuplerepeat() in Objects/tupleobject.c uses a questionable check that relies on 
signed integer overflow. It is a matter of time when this rifle will shoot in 
the foot. But I didn't expected issues with old good gcc 6.3. Was the 
interpreter compiled with non-standard options or ran on non-x86 platform?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue33156] Use super().method instead in email classes.

2018-03-27 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
type:  -> enhancement

___
Python tracker 

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



[issue33155] Use super().method instead in Logging

2018-03-27 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
nosy: +vinay.sajip
type:  -> enhancement
versions: +Python 3.8

___
Python tracker 

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



  1   2   >